Senior Member
Join Date: Apr 2017
Location: +2+2
|
04-28-2017
, 17:24
[TF2] Help with this plugin
|
#1
|
Hello guys, i've got a plugin that restrict some weapons depending of player class and giving another weapon if the previous is restricted, the plugin works well, but the only problem is that all melee weapons of all classes are replaced buy the "Kukri" the default weapon of Sniper, and i dont know why? can you help me? Here is the script:
PHP Code:
public OnPluginStart() { HookEvent("player_spawn", OnPlayerSpawn); }
public Action OnPlayerSpawn(Handle event, char[] name, bool dontBroadcast) { int client = GetClientOfUserId(GetEventInt(event, "userid")); new weapon = TF2Items_GiveWeapon(client, weapon); //TF2Items_SetItemIndex switch(TF2_GetPlayerClass(client)) { case TFClass_Scout: { if (IsSlotIndex(client, 0, 45)) //Force-a-nature { SwitchScout0(client); } if (IsSlotIndex(client, 0, 448)) //Soda-popper { SwitchScout0(client); } if (IsSlotIndex(client, 1, 449)) //Winger { SwitchScout1(client); } if (IsSlotIndex(client, 1, 46)) //Bonk { SwitchScout1(client); } if (IsSlotIndex(client, 1, 1145)) //Festive bonk { SwitchScout1(client); } if (IsSlotIndex(client, 2, 325)) //Boston-Basher { SwitchScout2(client); } if (IsSlotIndex(client, 2, 450)) //Atomizer { SwitchScout2(client); } if (IsSlotIndex(client, 2, 452)) //Three-Runes Blade { SwitchScout2(client); } } case TFClass_Sniper: { if (IsSlotIndex(client, 2, 171)) { TF2Items_GiveWeapon(client, 171); } } case TFClass_Soldier: { TF2_RemoveWeaponSlot(client, 0); } case TFClass_DemoMan: { TF2_RemoveWeaponSlot(client, 0); TF2_RemoveWeaponSlot(client, 1); } case TFClass_Medic: { TF2_RemoveWeaponSlot(client, 1); } case TFClass_Heavy: { if (IsSlotIndex(client, 1, 42)) { TF2Items_GiveWeapon(client, 42); } } case TFClass_Pyro: { if (IsSlotIndex(client, 1, 39)) { TF2Items_GiveWeapon(client, 12); } if (IsSlotIndex(client, 1, 351)) { TF2Items_GiveWeapon(client, 12); } if (IsSlotIndex(client, 1, 595)) { TF2Items_GiveWeapon(client, 12); } if (IsSlotIndex(client, 1, 740)) { TF2Items_GiveWeapon(client, 12); } if (IsSlotIndex(client, 1, 1081)) { TF2Items_GiveWeapon(client, 12); } } case TFClass_Spy: { TF2_RemoveWeaponSlot(client, 3); TF2_RemoveWeaponSlot(client, 4); } case TFClass_Engineer: { if (IsSlotIndex(client, 2, 589)) { SwitchEngineer2(client); } TF2_RemoveWeaponSlot(client, 3); TF2_RemoveWeaponSlot(client, 4); TF2_RemoveWeaponSlot(client, 5); } } }
public Action:SwitchScout0(client) { switch(GetRandomInt(1, 6)) { case 1: { TF2Items_GiveWeapon(client, 13); } case 2: { TF2Items_GiveWeapon(client, 220); } case 3: { TF2Items_GiveWeapon(client, 669); } case 4: { TF2Items_GiveWeapon(client, 1103); } case 5: { TF2Items_GiveWeapon(client, 772); } case 6: { TF2Items_GiveWeapon(client, 669); } } }
public Action:SwitchScout1(client) { switch(GetRandomInt(1, 6)) { case 1: { TF2Items_GiveWeapon(client, 23); } case 2: { TF2Items_GiveWeapon(client, 160); } case 3: { TF2Items_GiveWeapon(client, 222); } case 4: { TF2Items_GiveWeapon(client, 294); } case 5: { TF2Items_GiveWeapon(client, 1121); } case 6: { TF2Items_GiveWeapon(client, 812); } } }
public Action:SwitchScout2(client) { switch(GetRandomInt(1, 6)) { case 1: { TF2Items_GiveWeapon(client, 44); } case 2: { TF2Items_GiveWeapon(client, 221); } case 3: { TF2Items_GiveWeapon(client, 264); } case 4: { TF2Items_GiveWeapon(client, 317); } case 5: { TF2Items_GiveWeapon(client, 423); } case 6: { TF2Items_GiveWeapon(client, 660); } } }
public Action:SwitchEngineer2(client) { switch(GetRandomInt(1, 6)) { case 1: { TF2Items_GiveWeapon(client, 142); } case 2: { TF2Items_GiveWeapon(client, 155); } case 3: { TF2Items_GiveWeapon(client, 423); } case 4: { TF2Items_GiveWeapon(client, 169); } case 5: { TF2Items_GiveWeapon(client, 329); } case 6: { TF2Items_GiveWeapon(client, 30758); } } }
stock int GetIndexOfWeaponSlot(int client, int slot) { return GetWeaponIndex(GetPlayerWeaponSlot(client, slot)); } stock int GetWeaponIndex(int weapon) { return IsValidEnt(weapon) ? GetEntProp(weapon, Prop_Send, "m_iItemDefinitionIndex"):-1; } stock bool IsSlotIndex(int client, int slot, int index) { return index == GetIndexOfWeaponSlot(client, slot); } stock bool IsValidEnt(int ent) { return ent > MaxClients && IsValidEntity(ent); }
Last edited by Facksy; 04-28-2017 at 17:30.
|
|