SHOW:
|
|
- or go back to the newest paste.
| 1 | #pragma newdecls required | |
| 2 | ||
| 3 | #include <sourcemod> | |
| 4 | #include <sdktools> | |
| 5 | ||
| 6 | #define MAXLIST 11 | |
| 7 | ||
| 8 | int iWeapon[2048 + 1], iAmmo[MAXPLAYERS + 1][2][2]; | |
| 9 | bool iCookies[MAXPLAYERS + 1][2], iState[MAXPLAYERS + 1], IsMelee[MAXPLAYERS + 1][2], IsDual[MAXPLAYERS + 1][2]; | |
| 10 | char sClassnameWeapon[MAXPLAYERS + 1][2][36]; | |
| 11 | ||
| 12 | static const char gModelsItemsList[MAXLIST][] = | |
| 13 | {
| |
| 14 | "models/weapons/melee/v_katana.mdl", //0 | |
| 15 | "models/weapons/melee/v_fireaxe.mdl", //1 | |
| 16 | "models/weapons/melee/v_machete.mdl", //2 | |
| 17 | "models/weapons/melee/v_crowbar.mdl", //3 | |
| 18 | "models/v_models/v_knife_t.mdl", //4 | |
| 19 | - | if (StrEqual(sCommand, "say") || StrEqual(sCommand, "say_team")) |
| 19 | + | "models/weapons/melee/v_frying_pan.mdl", //5 |
| 20 | - | {
|
| 20 | + | "models/weapons/melee/v_bat.mdl", //6 |
| 21 | - | char sArg[2]; |
| 21 | + | "models/weapons/melee/v_cricket_bat.mdl", //7 |
| 22 | - | GetCmdArg(1, sArg, sizeof(sArg)); |
| 22 | + | "models/weapons/melee/v_tonfa.mdl", //8 |
| 23 | - | if(strcmp(sArg, "s") == 0) |
| 23 | + | "models/weapons/melee/v_electric_guitar.mdl", //9 |
| 24 | - | {
|
| 24 | + | "models/weapons/melee/v_golfclub.mdl" //10 |
| 25 | }; | |
| 26 | ||
| 27 | - | } |
| 27 | + | |
| 28 | - | } |
| 28 | + | |
| 29 | - | return Plugin_Continue; |
| 29 | + | |
| 30 | RegConsoleCmd("s", cSwitch);
| |
| 31 | RegConsoleCmd("sm_s", cSwitch);
| |
| 32 | } | |
| 33 | ||
| 34 | public Action HookPlayerChat(int iClient, const char[] sCommand, int iArgs) | |
| 35 | - | |
| 35 | + | |
| 36 | if (StrEqual(sCommand, "say") || StrEqual(sCommand, "say_team")) | |
| 37 | {
| |
| 38 | char sArg[2]; | |
| 39 | GetCmdArg(1, sArg, sizeof(sArg)); | |
| 40 | if(strcmp(sArg, "s") == 0) | |
| 41 | {
| |
| 42 | cSwitch(iClient, 0); | |
| 43 | return Plugin_Continue; | |
| 44 | } | |
| 45 | } | |
| 46 | return Plugin_Continue; | |
| 47 | } | |
| 48 | ||
| 49 | public Action cSwitch (int client, int args) | |
| 50 | - | |
| 50 | + | |
| 51 | int iSlot = GetPlayerWeaponSlot(client, 1), AmmoType, Ammo, iClip; | |
| 52 | ||
| 53 | if(!iState[client]) | |
| 54 | {
| |
| 55 | if(!iCookies[client][0]) | |
| 56 | {
| |
| 57 | - | |
| 57 | + | |
| 58 | {
| |
| 59 | GetEntityClassname(iSlot, sClassnameWeapon[client][0], sizeof sClassnameWeapon[][]); | |
| 60 | if(strcmp(sClassnameWeapon[client][0], "weapon_melee") == 0) | |
| 61 | {
| |
| 62 | IsMelee[client][0] = true; | |
| 63 | GetEntPropString(iSlot, Prop_Data, "m_strMapSetScriptName", sClassnameWeapon[client][0], sizeof sClassnameWeapon[][]); | |
| 64 | if(!sClassnameWeapon[client][0]) | |
| 65 | {
| |
| 66 | char ModelName[128], sExplodeString[MAXLIST - 6][36]; | |
| 67 | int iNum; | |
| 68 | GetEntPropString(iSlot, Prop_Data, "m_ModelName", ModelName, sizeof ModelName); | |
| 69 | for(int i; i < MAXLIST; i++) | |
| 70 | {
| |
| 71 | if(strcmp(ModelName, gModelsItemsList[i]) == 0) | |
| 72 | {
| |
| 73 | iNum = ExplodeString(gModelsItemsList[i], "/", sExplodeString, sizeof sExplodeString, sizeof sExplodeString[]); | |
| 74 | ReplaceString(sExplodeString[iNum - 1], sizeof sExplodeString[], "v_", ""); | |
| 75 | if(StrContains(sExplodeString[iNum - 1], "knife") > 0) | |
| 76 | ReplaceString(sExplodeString[iNum - 1], sizeof sExplodeString[], "_t.mdl", ""); | |
| 77 | else | |
| 78 | ReplaceString(sExplodeString[iNum - 1], sizeof sExplodeString[], ".mdl", ""); | |
| 79 | TrimString(sExplodeString[iNum - 1]); | |
| 80 | Format(sClassnameWeapon[client][0], sizeof sClassnameWeapon[][], "%s", sExplodeString[iNum - 1]); | |
| 81 | break; | |
| 82 | } | |
| 83 | - | |
| 83 | + | |
| 84 | } | |
| 85 | } | |
| 86 | else if(strcmp(sClassnameWeapon[client][0], "weapon_pistol") == 0 && GetEntProp(iSlot, Prop_Send, "m_hasDualWeapons")) | |
| 87 | IsDual[client][0] = true; | |
| 88 | ||
| 89 | if(!IsMelee[client][0]) | |
| 90 | {
| |
| 91 | AmmoType = GetEntProp(iSlot, Prop_Send, "m_iPrimaryAmmoType"); | |
| 92 | Ammo = GetEntProp(client, Prop_Send, "m_iAmmo", _, AmmoType); | |
| 93 | iClip = GetEntProp(iSlot, Prop_Send, "m_iClip1"); | |
| 94 | } | |
| 95 | ||
| 96 | iAmmo[client][0][0] = iClip; | |
| 97 | iAmmo[client][0][1] = Ammo; | |
| 98 | ||
| 99 | RemovePlayerItem(client, iSlot); | |
| 100 | AcceptEntityInput(iSlot, "kill"); | |
| 101 | iCookies[client][0] = true; | |
| 102 | if(iCookies[client][1]) | |
| 103 | {
| |
| 104 | iSlot = GetPlayerWeaponSlot(client, 1); | |
| 105 | if(!IsValidEntity(iSlot)) | |
| 106 | {
| |
| 107 | if(!IsMelee[client][1]) | |
| 108 | {
| |
| 109 | if(IsDual[client][1]) | |
| 110 | {
| |
| 111 | int entity; | |
| 112 | for(int i; i <= 2; i++) | |
| 113 | {
| |
| 114 | entity = CreateEntityByName(sClassnameWeapon[client][1]); | |
| 115 | DispatchSpawn(entity); | |
| 116 | if(IsValidEntity(entity)) | |
| 117 | {
| |
| 118 | AcceptEntityInput(entity, "Use", client); | |
| 119 | } | |
| 120 | } | |
| 121 | ||
| 122 | iWeapon[entity] = GetClientUserId(client); | |
| 123 | CreateTimer(0.02, tXclip2, EntIndexToEntRef(entity)); | |
| 124 | iCookies[client][1] = false; | |
| 125 | IsDual[client][1] = false; | |
| 126 | } | |
| 127 | else | |
| 128 | {
| |
| 129 | int entity = CreateEntityByName(sClassnameWeapon[client][1]); | |
| 130 | DispatchSpawn(entity); | |
| 131 | if(IsValidEntity(entity)) | |
| 132 | - | |
| 132 | + | |
| 133 | AcceptEntityInput(entity, "Use", client); | |
| 134 | iCookies[client][1] = false; | |
| 135 | } | |
| 136 | iWeapon[entity] = GetClientUserId(client); | |
| 137 | CreateTimer(0.02, tXclip2, EntIndexToEntRef(entity)); | |
| 138 | } | |
| 139 | } | |
| 140 | else | |
| 141 | {
| |
| 142 | int entity = MeleeAwfull(sClassnameWeapon[client][1]); | |
| 143 | AcceptEntityInput(entity, "Use", client); | |
| 144 | iCookies[client][1] = false; | |
| 145 | IsMelee[client][1] = false; | |
| 146 | } | |
| 147 | } | |
| 148 | } | |
| 149 | } | |
| 150 | } | |
| 151 | else | |
| 152 | {
| |
| 153 | iSlot = GetPlayerWeaponSlot(client, 1); | |
| 154 | if(!IsValidEntity(iSlot)) | |
| 155 | {
| |
| 156 | if(!IsMelee[client][0]) | |
| 157 | {
| |
| 158 | if(IsDual[client][0]) | |
| 159 | {
| |
| 160 | int entity; | |
| 161 | for(int i; i <= 2; i++) | |
| 162 | {
| |
| 163 | entity = CreateEntityByName(sClassnameWeapon[client][0]); | |
| 164 | DispatchSpawn(entity); | |
| 165 | if(IsValidEntity(entity)) | |
| 166 | {
| |
| 167 | AcceptEntityInput(entity, "Use", client); | |
| 168 | } | |
| 169 | } | |
| 170 | ||
| 171 | iWeapon[entity] = GetClientUserId(client); | |
| 172 | CreateTimer(0.02, tXclip, EntIndexToEntRef(entity)); | |
| 173 | iCookies[client][0] = false; | |
| 174 | IsDual[client][0] = false; | |
| 175 | } | |
| 176 | else | |
| 177 | {
| |
| 178 | int entity = CreateEntityByName(sClassnameWeapon[client][0]); | |
| 179 | DispatchSpawn(entity); | |
| 180 | if(IsValidEntity(entity)) | |
| 181 | {
| |
| 182 | AcceptEntityInput(entity, "Use", client); | |
| 183 | iCookies[client][0] = false; | |
| 184 | } | |
| 185 | iWeapon[entity] = GetClientUserId(client); | |
| 186 | CreateTimer(0.02, tXclip, EntIndexToEntRef(entity)); | |
| 187 | } | |
| 188 | } | |
| 189 | else | |
| 190 | {
| |
| 191 | int entity = MeleeAwfull(sClassnameWeapon[client][0]); | |
| 192 | AcceptEntityInput(entity, "Use", client); | |
| 193 | iCookies[client][0] = false; | |
| 194 | IsMelee[client][0] = false; | |
| 195 | } | |
| 196 | } | |
| 197 | } | |
| 198 | iState[client] = true; | |
| 199 | } | |
| 200 | else | |
| 201 | {
| |
| 202 | if(!iCookies[client][1]) | |
| 203 | {
| |
| 204 | if(IsValidEntity(iSlot)) | |
| 205 | {
| |
| 206 | GetEntityClassname(iSlot, sClassnameWeapon[client][1], sizeof sClassnameWeapon[][]); | |
| 207 | if(strcmp(sClassnameWeapon[client][1], "weapon_melee") == 0) | |
| 208 | {
| |
| 209 | IsMelee[client][1] = true; | |
| 210 | GetEntPropString(iSlot, Prop_Data, "m_strMapSetScriptName", sClassnameWeapon[client][1], sizeof sClassnameWeapon[][]); | |
| 211 | if(!sClassnameWeapon[client][1]) | |
| 212 | {
| |
| 213 | char ModelName[128], sExplodeString[MAXLIST - 6][36]; | |
| 214 | int iNum; | |
| 215 | GetEntPropString(iSlot, Prop_Data, "m_ModelName", ModelName, sizeof ModelName); | |
| 216 | for(int i; i < MAXLIST; i++) | |
| 217 | {
| |
| 218 | if(strcmp(ModelName, gModelsItemsList[i]) == 0) | |
| 219 | {
| |
| 220 | iNum = ExplodeString(gModelsItemsList[i], "/", sExplodeString, sizeof sExplodeString, sizeof sExplodeString[]); | |
| 221 | ReplaceString(sExplodeString[iNum - 1], sizeof sExplodeString[], "v_", ""); | |
| 222 | if(StrContains(sExplodeString[iNum - 1], "knife") > 0) | |
| 223 | ReplaceString(sExplodeString[iNum - 1], sizeof sExplodeString[], "_t.mdl", ""); | |
| 224 | else | |
| 225 | ReplaceString(sExplodeString[iNum - 1], sizeof sExplodeString[], ".mdl", ""); | |
| 226 | TrimString(sExplodeString[iNum - 1]); | |
| 227 | Format(sClassnameWeapon[client][1], sizeof sClassnameWeapon[][], "%s", sExplodeString[iNum - 1]); | |
| 228 | break; | |
| 229 | } | |
| 230 | } | |
| 231 | } | |
| 232 | } | |
| 233 | else if(strcmp(sClassnameWeapon[client][1], "weapon_pistol") == 0 && GetEntProp(iSlot, Prop_Send, "m_hasDualWeapons")) | |
| 234 | {
| |
| 235 | IsDual[client][1] = true; | |
| 236 | } | |
| 237 | ||
| 238 | if(!IsMelee[client][1]) | |
| 239 | {
| |
| 240 | AmmoType = GetEntProp(iSlot, Prop_Send, "m_iPrimaryAmmoType"); | |
| 241 | Ammo = GetEntProp(client, Prop_Send, "m_iAmmo", _, AmmoType); | |
| 242 | iClip = GetEntProp(iSlot, Prop_Send, "m_iClip1"); | |
| 243 | } | |
| 244 | ||
| 245 | iAmmo[client][1][0] = iClip; | |
| 246 | iAmmo[client][1][1] = Ammo; | |
| 247 | ||
| 248 | RemovePlayerItem(client, iSlot); | |
| 249 | AcceptEntityInput(iSlot, "kill"); | |
| 250 | iCookies[client][1] = true; | |
| 251 | if(iCookies[client][0]) | |
| 252 | {
| |
| 253 | iSlot = GetPlayerWeaponSlot(client, 1); | |
| 254 | if(!IsMelee[client][0]) | |
| 255 | {
| |
| 256 | if(IsDual[client][0]) | |
| 257 | {
| |
| 258 | int entity; | |
| 259 | for(int i; i <= 2; i++) | |
| 260 | {
| |
| 261 | entity = CreateEntityByName(sClassnameWeapon[client][0]); | |
| 262 | DispatchSpawn(entity); | |
| 263 | if(IsValidEntity(entity)) | |
| 264 | {
| |
| 265 | AcceptEntityInput(entity, "Use", client); | |
| 266 | } | |
| 267 | } | |
| 268 | iWeapon[entity] = GetClientUserId(client); | |
| 269 | CreateTimer(0.02, tXclip, EntIndexToEntRef(entity)); | |
| 270 | iCookies[client][0] = false; | |
| 271 | IsDual[client][0] = false; | |
| 272 | } | |
| 273 | else | |
| 274 | {
| |
| 275 | int entity = CreateEntityByName(sClassnameWeapon[client][0]); | |
| 276 | DispatchSpawn(entity); | |
| 277 | if(IsValidEntity(entity)) | |
| 278 | {
| |
| 279 | AcceptEntityInput(entity, "Use", client); | |
| 280 | iCookies[client][0] = false; | |
| 281 | } | |
| 282 | iWeapon[entity] = GetClientUserId(client); | |
| 283 | CreateTimer(0.02, tXclip, EntIndexToEntRef(entity)); | |
| 284 | } | |
| 285 | } | |
| 286 | else | |
| 287 | {
| |
| 288 | int entity = MeleeAwfull(sClassnameWeapon[client][0]); | |
| 289 | AcceptEntityInput(entity, "Use", client); | |
| 290 | iCookies[client][0] = false; | |
| 291 | IsMelee[client][0] = false; | |
| 292 | } | |
| 293 | } | |
| 294 | } | |
| 295 | } | |
| 296 | else | |
| 297 | {
| |
| 298 | iSlot = GetPlayerWeaponSlot(client, 1); | |
| 299 | if(!IsValidEntity(iSlot)) | |
| 300 | - | |
| 300 | + | |
| 301 | if(!IsMelee[client][1]) | |
| 302 | {
| |
| 303 | if(IsDual[client][1]) | |
| 304 | {
| |
| 305 | int entity; | |
| 306 | for(int i; i <= 2; i++) | |
| 307 | {
| |
| 308 | entity = CreateEntityByName(sClassnameWeapon[client][1]); | |
| 309 | DispatchSpawn(entity); | |
| 310 | if(IsValidEntity(entity)) | |
| 311 | {
| |
| 312 | AcceptEntityInput(entity, "Use", client); | |
| 313 | } | |
| 314 | } | |
| 315 | iWeapon[entity] = GetClientUserId(client); | |
| 316 | CreateTimer(0.02, tXclip2, EntIndexToEntRef(entity)); | |
| 317 | iCookies[client][1] = false; | |
| 318 | IsDual[client][1] = false; | |
| 319 | } | |
| 320 | - | |
| 320 | + | |
| 321 | {
| |
| 322 | int entity = CreateEntityByName(sClassnameWeapon[client][1]); | |
| 323 | DispatchSpawn(entity); | |
| 324 | if(IsValidEntity(entity)) | |
| 325 | {
| |
| 326 | AcceptEntityInput(entity, "Use", client); | |
| 327 | iCookies[client][1] = false; | |
| 328 | } | |
| 329 | iWeapon[entity] = GetClientUserId(client); | |
| 330 | CreateTimer(0.02, tXclip2, EntIndexToEntRef(entity)); | |
| 331 | } | |
| 332 | } | |
| 333 | else | |
| 334 | {
| |
| 335 | int entity = MeleeAwfull(sClassnameWeapon[client][1]); | |
| 336 | - | |
| 336 | + | |
| 337 | iCookies[client][1] = false; | |
| 338 | - | GetEntPropString(iMWeapon, Prop_Data, "m_ModelName", ModelName, sizeof ModelName); |
| 338 | + | |
| 339 | - | |
| 339 | + | |
| 340 | } | |
| 341 | } | |
| 342 | iState[client] = false; | |
| 343 | } | |
| 344 | return Plugin_Handled; | |
| 345 | } | |
| 346 | ||
| 347 | public Action tXclip(Handle timer, int entity) | |
| 348 | {
| |
| 349 | entity = EntRefToEntIndex(entity); | |
| 350 | if(entity != INVALID_ENT_REFERENCE) | |
| 351 | {
| |
| 352 | int iAmmoType = GetEntProp(entity, Prop_Send, "m_iPrimaryAmmoType"); | |
| 353 | if(iAmmoType) | |
| 354 | {
| |
| 355 | int Clip, Ammo, client; | |
| 356 | client = GetClientOfUserId(iWeapon[entity]); | |
| 357 | Clip = iAmmo[client][0][0]; | |
| 358 | Ammo = iAmmo[client][0][1]; | |
| 359 | ||
| 360 | int iCurrentWeapon = GetPlayerWeaponSlot(client, 1); | |
| 361 | SetEntProp(client, Prop_Send, "m_iAmmo", Ammo, _, iAmmoType); | |
| 362 | SetEntProp(iCurrentWeapon, Prop_Send, "m_iClip1", Clip); | |
| 363 | } | |
| 364 | } | |
| 365 | } | |
| 366 | ||
| 367 | public Action tXclip2(Handle timer, int entity) | |
| 368 | {
| |
| 369 | entity = EntRefToEntIndex(entity); | |
| 370 | if(entity != INVALID_ENT_REFERENCE) | |
| 371 | {
| |
| 372 | int iAmmoType = GetEntProp(entity, Prop_Send, "m_iPrimaryAmmoType"); | |
| 373 | if(iAmmoType) | |
| 374 | {
| |
| 375 | int Clip, Ammo, client; | |
| 376 | client = GetClientOfUserId(iWeapon[entity]); | |
| 377 | Clip = iAmmo[client][1][0]; | |
| 378 | Ammo = iAmmo[client][1][1]; | |
| 379 | ||
| 380 | int iCurrentWeapon = GetPlayerWeaponSlot(client, 1); | |
| 381 | SetEntProp(client, Prop_Send, "m_iAmmo", Ammo, _, iAmmoType); | |
| 382 | SetEntProp(iCurrentWeapon, Prop_Send, "m_iClip1", Clip); | |
| 383 | } | |
| 384 | } | |
| 385 | } | |
| 386 | ||
| 387 | int MeleeAwfull(const char[] Melee) | |
| 388 | {
| |
| 389 | int iMWeapon = CreateEntityByName("weapon_melee");
| |
| 390 | ||
| 391 | if (IsValidEntity(iMWeapon)) | |
| 392 | {
| |
| 393 | DispatchKeyValue(iMWeapon, "melee_script_name", Melee); | |
| 394 | DispatchSpawn(iMWeapon); | |
| 395 | ||
| 396 | char ModelName[128]; | |
| 397 | GetEntPropString(iMWeapon, Prop_Data, "m_ModelName", ModelName, sizeof ModelName); | |
| 398 | ||
| 399 | if (StrContains( ModelName, "hunter", false ) != -1) | |
| 400 | AcceptEntityInput(iMWeapon, "kill"); | |
| 401 | } | |
| 402 | return iMWeapon; | |
| 403 | } |