This site is a testing version, but all data is shared with the live forum.


Raised This Month: $ Target: $400
 0% 

[TF2] Help with this plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Facksy
Senior Member
Join Date: Apr 2017
Location: +2+2
Old 04-28-2017 , 17:24   [TF2] Help with this plugin
Reply With Quote #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 eventchar[] namebool dontBroadcast)
{
    
int client GetClientOfUserId(GetEventInt(event"userid"));
    new 
weapon TF2Items_GiveWeapon(clientweapon);                        //TF2Items_SetItemIndex
    
    
switch(TF2_GetPlayerClass(client))
    {
        case 
TFClass_Scout:
        {
            if (
IsSlotIndex(client045))      //Force-a-nature
            
{
                
SwitchScout0(client);
            }
                
            if (
IsSlotIndex(client0448))     //Soda-popper
            
{
                
SwitchScout0(client);
            }
               
            if (
IsSlotIndex(client1449))     //Winger
            
{
                
SwitchScout1(client);
            }
                
            if (
IsSlotIndex(client146))      //Bonk
            
{
                
SwitchScout1(client);
            }
                
            if (
IsSlotIndex(client11145))    //Festive bonk
            
{
                
SwitchScout1(client);
            }
                
            if (
IsSlotIndex(client2325))     //Boston-Basher
            
{
                
SwitchScout2(client);
            }
                
            if (
IsSlotIndex(client2450))     //Atomizer
            
{
                
SwitchScout2(client);
            }
               
            if (
IsSlotIndex(client2452))     //Three-Runes Blade
            
{
                
SwitchScout2(client);
            }
        }
        case 
TFClass_Sniper:
        {
            if (
IsSlotIndex(client2171))
            {
                
TF2Items_GiveWeapon(client171);
            }
        }
        case 
TFClass_Soldier:
        {
            
TF2_RemoveWeaponSlot(client0);
        }        
        case 
TFClass_DemoMan:
        {
            
TF2_RemoveWeaponSlot(client0);
            
TF2_RemoveWeaponSlot(client1);
        }
        case 
TFClass_Medic:
        {
            
TF2_RemoveWeaponSlot(client1);
        }
        case 
TFClass_Heavy:
        {
            if (
IsSlotIndex(client142))
            {
                
TF2Items_GiveWeapon(client42);
            }
        }
        case 
TFClass_Pyro:
        {
            if (
IsSlotIndex(client139))
            {
                
TF2Items_GiveWeapon(client12);
            }
               
            if (
IsSlotIndex(client1351))
            {
                
TF2Items_GiveWeapon(client12);
            }
                
            if (
IsSlotIndex(client1595))
            {
                
TF2Items_GiveWeapon(client12);
            }
               
            if (
IsSlotIndex(client1740))
            {
                
TF2Items_GiveWeapon(client12);
            }
                
             if (
IsSlotIndex(client11081))
            {
                
TF2Items_GiveWeapon(client12);
            }
        }
        case 
TFClass_Spy:
        {
            
TF2_RemoveWeaponSlot(client3);
            
TF2_RemoveWeaponSlot(client4);
        }
        case 
TFClass_Engineer:
        {
            if (
IsSlotIndex(client2589))
            {
                
SwitchEngineer2(client);
            }
            
TF2_RemoveWeaponSlot(client3);
             
TF2_RemoveWeaponSlot(client4);
            
TF2_RemoveWeaponSlot(client5);
        }
    }     
}


public 
Action:SwitchScout0(client)
{
    switch(
GetRandomInt(16)) 
    { 
        case 
1
        { 
            
TF2Items_GiveWeapon(client13);
        } 
        case 
2
        { 
            
TF2Items_GiveWeapon(client220); 
        } 
        case 
3
        { 
            
TF2Items_GiveWeapon(client669);
        } 
        case 
4
        { 
            
TF2Items_GiveWeapon(client1103);
        } 
        case 
5
        { 
            
TF2Items_GiveWeapon(client772);
        } 
        case 
6
        { 
            
TF2Items_GiveWeapon(client669);
        } 
    } 
}

public 
Action:SwitchScout1(client)
{
    switch(
GetRandomInt(16)) 
    { 
        case 
1
        { 
            
TF2Items_GiveWeapon(client23);
        } 
        case 
2
        { 
            
TF2Items_GiveWeapon(client160); 
        } 
        case 
3
        { 
            
TF2Items_GiveWeapon(client222);
        } 
        case 
4
        { 
            
TF2Items_GiveWeapon(client294);
        } 
        case 
5
        { 
            
TF2Items_GiveWeapon(client1121);
        } 
        case 
6
        { 
            
TF2Items_GiveWeapon(client812);
        } 
    } 
}

public 
Action:SwitchScout2(client)
{
    switch(
GetRandomInt(16)) 
    { 
        case 
1
        { 
            
TF2Items_GiveWeapon(client44);
        } 
        case 
2
        { 
            
TF2Items_GiveWeapon(client221); 
        } 
        case 
3
        { 
            
TF2Items_GiveWeapon(client264);
        } 
        case 
4
        { 
            
TF2Items_GiveWeapon(client317);
        } 
        case 
5
        { 
            
TF2Items_GiveWeapon(client423);
        } 
        case 
6
        { 
            
TF2Items_GiveWeapon(client660);
        } 
    } 
}

public 
Action:SwitchEngineer2(client)
{
    switch(
GetRandomInt(16)) 
    { 
        case 
1
        { 
            
TF2Items_GiveWeapon(client142);
        } 
        case 
2
        { 
            
TF2Items_GiveWeapon(client155); 
        } 
        case 
3
        { 
            
TF2Items_GiveWeapon(client423);
        } 
        case 
4
        { 
            
TF2Items_GiveWeapon(client169);
        } 
        case 
5
        { 
            
TF2Items_GiveWeapon(client329);
        } 
        case 
6
        { 
            
TF2Items_GiveWeapon(client30758);
        } 
    } 
}


stock int GetIndexOfWeaponSlot(int clientint slot)
{
    return 
GetWeaponIndex(GetPlayerWeaponSlot(clientslot));
}
 
stock int GetWeaponIndex(int weapon)
{
    return 
IsValidEnt(weapon) ? GetEntProp(weaponProp_Send"m_iItemDefinitionIndex"):-1;
}
 
stock bool IsSlotIndex(int clientint slotint index)
{
    return 
index == GetIndexOfWeaponSlot(clientslot);
}
 
stock bool IsValidEnt(int ent)
{
    return 
ent MaxClients && IsValidEntity(ent);


Last edited by Facksy; 04-28-2017 at 17:30.
Facksy is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 05:56.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode