cs_weapons_api_stocks.inc

Original include source with line numbers.

Back Download .inc
1 #if defined _cswa_stocks_included
2 #endinput
3 #endif
4 #define _cswa_stocks_included
5
6 #if !defined _cswa_included
7 #include <cs_weapons_api>
8 #endif
9
10 stock const Float:g_fReloadTime[] =
11 {
12 0.00, // NULL
13 2.70, // CSW_P228
14 0.00, // NULL
15 2.00, // CSW_SCOUT
16 0.00, // CSW_HEGRENADE
17 0.55, // CSW_XM1014
18 0.00, // CSW_C4
19 3.15, // CSW_MAC10
20 3.30, // CSW_AUG
21 0.00, // CSW_SMOKEGRENADE
22 4.50, // CSW_ELITE
23 2.70, // CSW_FIVESEVEN
24 3.50, // CSW_UMP45
25 3.35, // CSW_SG550
26 2.45, // CSW_GALIL
27 3.30, // CSW_FAMAS
28 2.70, // CSW_USP
29 2.20, // CSW_GLOCK
30 2.50, // CSW_AWP
31 2.63, // CSW_MP5NAVY
32 4.70, // CSW_M249
33 0.55, // CSW_M3
34 3.05, // CSW_M4A1
35 2.12, // CSW_TMP
36 3.50, // CSW_G3SG1
37 0.00, // CSW_FLASHBANG
38 2.20, // CSW_DEAGLE
39 3.00, // CSW_SG552
40 2.45, // CSW_AK47
41 0.00, // CSW_KNIFE
42 3.40 // CSW_P90
43 };
44
45 stock const g_iWeaponSlots[] =
46 {
47 0, // NULL
48 2, // CSW_P228
49 0, // NULL
50 1, // CSW_SCOUT
51 4, // CSW_HEGRENADE
52 1, // CSW_XM1014
53 5, // CSW_C4
54 1, // CSW_MAC10
55 1, // CSW_AUG
56 4, // CSW_SMOKEGRENADE
57 2, // CSW_ELITE
58 2, // CSW_FIVESEVEN
59 1, // CSW_UMP45
60 1, // CSW_SG550
61 1, // CSW_GALIL
62 1, // CSW_FAMAS
63 2, // CSW_USP
64 2, // CSW_GLOCK
65 1, // CSW_AWP
66 1, // CSW_MP5NAVY
67 1, // CSW_M249
68 1, // CSW_M3
69 1, // CSW_M4A1
70 1, // CSW_TMP
71 1, // CSW_G3SG1
72 4, // CSW_FLASHBANG
73 2, // CSW_DEAGLE
74 1, // CSW_SG552
75 1, // CSW_AK47
76 3, // CSW_KNIFE
77 1 // CSW_P90
78 };
79
80 stock ham_strip_weapon(id, const weapon[])
81 {
82 if(!is_user_alive(id))
83 return 0;
84
85 new weapon_ent = find_ent_by_owner(-1, weapon, id);
86 if(!weapon_ent)
87 return 0;
88
89 new weapon_id = get_weaponid(weapon);
90 if(!weapon_id)
91 return 0;
92
93 if(get_user_weapon(id) == weapon_id)
94 ExecuteHamB(Ham_Weapon_RetireWeapon, weapon_ent);
95
96 if(!ExecuteHamB(Ham_RemovePlayerItem, id, weapon_ent))
97 return 0;
98
99 user_has_weapon(id, weapon_id, 0);
100 ExecuteHamB(Ham_Item_Kill, weapon_ent);
101 remove_user_shield(id);
102 //set_pev(id, pev_weapons, pev(id, pev_weapons) & ~(1<<weapon_id));
103
104 return 1;
105 }
106
107 stock ham_give_weapon(id, weapon[], val = 0)
108 {
109 if(!is_user_alive(id))
110 return 0;
111
112 if(!equal(weapon, "weapon_", 7))
113 return 0;
114
115 new ent = create_entity(weapon);
116 if(!is_valid_ent(ent))
117 return 0;
118
119 entity_set_int(ent, EV_INT_spawnflags, SF_NORESPAWN);
120 DispatchSpawn(ent);
121
122 if(!ExecuteHamB(Ham_AddPlayerItem, id, ent))
123 {
124 if(is_valid_ent(ent))
125 entity_set_int(ent, EV_INT_flags, entity_get_int(ent, EV_INT_flags) | FL_KILLME);
126 return 0;
127 }
128
129 ExecuteHamB(Ham_Item_AttachToPlayer, ent, id);
130 if(val && !is_user_bot(id))
131 //ExecuteHamB(Ham_Item_Deploy, fm_find_ent_by_owner(-1, weapon, id));
132 show_weapon(id, weapon);
133
134 return ent;
135 }
136
137 stock show_weapon(id, weapon[])
138 {
139 if(is_user_bot(id))
140 return;
141
142 if(user_has_weapon(id, get_weaponid(weapon)))
143 ExecuteHamB(Ham_Item_Deploy, find_ent_by_owner(-1, weapon, id));
144
145 engclient_cmd(id, weapon);
146 }
147
148 stock no_ammo_weapon(weapon_id)
149 {
150 if(weapon_id == CSW_KNIFE || weapon_id == CSW_HEGRENADE || weapon_id == CSW_SMOKEGRENADE || weapon_id == CSW_FLASHBANG
151 || weapon_id == CSW_C4)
152 return 1;
153
154 return 0;
155 }
156
157 stock get_weapon_owner(ent)
158 return get_pdata_cbase(ent, 41, 4);
159
160 stock slot_filled(id, slot)
161 return get_pdata_cbase(id, 367+slot) > 0;
162
163 stock check_player_slot(id, weapon_ent)
164 {
165 new slot = ExecuteHam(Ham_Item_ItemSlot, weapon_ent);
166 if(slot_filled(id, slot) && !user_has_weapon(id, cs_get_weapon_id(weapon_ent)))
167 return 1;
168
169 return 0;
170 }
171
172 stock UTIL_PlayWeaponAnimation(const id, const seq)
173 {
174 set_pev(id, pev_weaponanim, seq);
175
176 message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, _, id);
177 write_byte(seq);
178 write_byte(pev(id, pev_body));
179 message_end();
180 }