Skocz do zawartości

Witamy w Nieoficjalnym polskim support'cie AMX Mod X

Witamy w Nieoficjalnym polskim support'cie AMX Mod X, jak w większości społeczności internetowych musisz się zarejestrować aby móc odpowiadać lub zakładać nowe tematy, ale nie bój się to jest prosty proces w którym wymagamy minimalnych informacji.
  • Rozpoczynaj nowe tematy i odpowiedaj na inne
  • Zapisz się do tematów i for, aby otrzymywać automatyczne uaktualnienia
  • Dodawaj wydarzenia do kalendarza społecznościowego
  • Stwórz swój własny profil i zdobywaj nowych znajomych
  • Zdobywaj nowe doświadczenia

Dołączona grafika Dołączona grafika

Guest Message by DevFuse
 

Wklejka 131597115511719 dodana przez WazzaP, 14.09.2011 04:32
Typ:


131597115511719
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
81.
82.
83.
84.
85.
86.
87.
88.
89.
90.
91.
92.
93.
94.
95.
96.
97.
98.
99.
100.
101.
102.
103.
104.
105.
106.
107.
108.
109.
110.
111.
112.
113.
114.
115.
116.
117.
118.
119.
120.
121.
122.
123.
124.
125.
126.
127.
128.
129.
130.
131.
132.
133.
134.
135.
136.
137.
138.
139.
140.
141.
142.
143.
144.
145.
146.
147.
148.
149.
150.
151.
152.
153.
154.
155.
156.
157.
158.
159.
160.
161.
162.
163.
164.
165.
166.
167.
168.
169.
170.
171.
172.
173.
174.
175.
176.
177.
178.
179.
180.
181.
182.
183.
184.
185.
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fakemeta>
#include <hamsandwich>
 
#define TID_RESTORE_ORIGIN 457547
 
new Float:_pg_ftmp
#define _Vec3ToAngles(%1,%2) _pg_ftmp = floatsqroot(%1[0]*%1[0] + %1[1]*%1[1]);\
    %2[1] = floatacos(%1[0]/_pg_ftmp, 1)*(1-2*_:(%1[1]<0));\
    %2[0] =-floatatan(%1[2]/_pg_ftmp, 1);\
    %2[2] = 0.0
 
#define _Vec3SetScalar(%1,%2) %1[0]=%2;%1[1]=%2;%1[2]=%2
#define _Vec3MultScalar(%1,%2) %1[0]*=%2;%1[1]*=%2;%1[2]*=%2
#define _Vec3Set(%1,%2) %1[0]=%2[0];%1[1]=%2[1];%1[2]=%2[2]
#define _Vec3Add(%1,%2) %1[0]+=%2[0];%1[1]+=%2[1];%1[2]+=%2[2]    
 
#define _Set(%1,%2) %1|=1<<%2
#define _Clear(%1,%2) %1&=~(1<<%2)
#define _Is(%1,%2) (%1&1<<%2)
new _human
new _alive
 
#define _IsPlayer(%1) (1<=%1<=g_max_players)
 
 
new g_max_players
new g_msg_saytext
new Float:g_t_origin[3]
new Float:g_b_origin[3]
new bool:g_valid_origin
new bool:g_ml
 
 
public plugin_init(){
    register_plugin("Replace Disconnected T", "1.4", "Sylwester")
    RegisterHam(Ham_Use, "func_button", "button_pushed", 1)
    RegisterHam(Ham_Spawn, "player", "Player_Spawn", 1)
    RegisterHam(Ham_Killed, "player", "Player_Killed", 1)
    g_max_players = get_maxplayers()
    g_msg_saytext = get_user_msgid("SayText")
 
    new path[128]
    get_datadir(path, 127)
    add(path, 127, "/lang/replace_disconnected_t.txt")
    if(file_exists(path)){
        register_dictionary("replace_disconnected_t.txt")
        g_ml = true
    }
}
 
 
public button_pushed(ent, idcaller, idactivator, use_type, Float:value){
    if(!_IsPlayer(idcaller) || !_Is(_alive, idcaller) || !pev_valid(ent))
        return
    new Float:ftmp[3]
    pev(ent, pev_mins, g_b_origin)
    pev(ent, pev_maxs, ftmp)
 
    _Vec3Add(g_b_origin, ftmp)
    _Vec3MultScalar(g_b_origin, 0.5) 
 
    pev(idcaller, pev_origin, g_t_origin)
    if(pev(idcaller, pev_flags) & FL_DUCKING)
        g_t_origin[2] += 19
    g_valid_origin = true
}
 
 
public Player_Killed(id){
    _Clear(_alive, id)
}
 
 
public Player_Spawn(id){
    if(!is_user_alive(id))
        return
    _Set(_alive, id)
    if(cs_get_user_team(id) != CS_TEAM_T)
        return
    g_valid_origin = false
}
 
 
public client_putinserver(id){
    if(is_user_bot(id) || is_user_hltv(id)) 
        return
    _Set(_human, id)
}
 
 
public announce_t_change(newid, oldid){
    new msg[160], otname[32], ntname[32]
    get_user_name(oldid, otname, 31)
    get_user_name(newid, ntname, 31)
    if(!g_ml){
        formatex(msg, 159, "^1[^3DeathRun^1] ^4%s^1 has left the game, the new Terrorist is ^4%s", otname, ntname)
        message_begin(MSG_ALL, g_msg_saytext, _, 0)
        write_byte(oldid)
        write_string(msg)
        message_end()    
        return
    }
    for(new i=1; i<=g_max_players; i++){
        if(!_Is(_human, i))
            continue
        formatex(msg, 159, "%L", i, "ANN_REPL_T", otname, ntname)         
        message_begin(MSG_ONE, g_msg_saytext, _, i)
        write_byte(oldid)
        write_string(msg)
        message_end()
    }
}
 
 
public client_disconnect(id){  
    _Clear(_human, id)
    _Clear(_alive, id)
    new players[32], pnum
    for(new i=1; i<=g_max_players; i++){
        if(!_Is(_human, i))
            continue
        if(cs_get_user_team(i) == CS_TEAM_T)
            return
        players[pnum++] = i
    }
    if(pnum<=0)
        return
    new new_terr = players[random(pnum)]
    cs_set_user_team(new_terr, CS_TEAM_T)
 
    announce_t_change(new_terr, id)
 
    if(!g_valid_origin){
        ExecuteHamB(Ham_CS_RoundRespawn, new_terr)
        return
    }
    ExecuteHamB(Ham_CS_RoundRespawn, new_terr)
    g_valid_origin = true
    new param[2]
    param[0] = new_terr
    param[1] = 10 //max teleport attempts
    restore_origin(param)
}
 
 
public restore_origin(param[]) {
    if(!g_valid_origin || --param[1]<0 || !_Is(_alive, param[0]))
        return
    new tr, Float:ftmp[3]
    _Vec3Set(ftmp, g_t_origin)
 
    //find vacant location
    for(new i=0; i<100; i++){      
        engfunc(EngFunc_TraceHull, ftmp, ftmp, 0, HULL_HUMAN, 0, tr)
        if(get_tr2(tr, TR_StartSolid) || get_tr2(tr, TR_AllSolid)){
            _Vec3SetScalar(ftmp, random_float(-10.0, 10.0))
            continue
        }   
        //check if new location is on the correct side of the wall
        engfunc(EngFunc_TraceLine, g_t_origin, ftmp, DONT_IGNORE_MONSTERS, 0, tr)
        new Float:fraction
        get_tr2(tr, TR_flFraction, fraction)
        if(fraction != 1.0){
            break
        }
        _Vec3Set(g_t_origin, ftmp)     
 
        set_pev(param[0], pev_origin, g_t_origin) //move player to vacant location
 
        //calculate angles
        _Vec3Set(ftmp, -g_t_origin)        
        _Vec3Add(ftmp, g_b_origin)
        _Vec3ToAngles(ftmp, ftmp)
 
        //aim at button
        set_pev(param[0], pev_angles, ftmp)
        set_pev(param[0], pev_fixangle, 1)
        return
    }
    set_task(0.1, "restore_origin", TID_RESTORE_ORIGIN+param[0], param, 2)
}