Raised This Month: $32 Target: $400
 8% 

Plugin using TF2Items keep creating Valve quality weapons.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Astrak
Junior Member
Join Date: Jan 2014
Location: 'Straya
Old 12-20-2014 , 09:07   Plugin using TF2Items keep creating Valve quality weapons.
Reply With Quote #1

So I run a Jailbreak server and I needed to block some weapons. I decided to try and make a plugin using TF2Items to replace the items with the stock counterparts. The code works fine but for some reason, every so often the weapon will be replaced with a Valve quality version of the replacement and I have no idea what could possibly be causing it.
I've been compiling the plugin on Sourcemod build 1.7.0-git5105.

My code (horrendous, I know) is below. Anything standing out?
PHP Code:
BlockWeapons(clientblockidreplacementidString:classname[])
{
    new 
slot1 GetPlayerWeaponSlot(client0);
    new 
slot2 GetPlayerWeaponSlot(client1);
    new 
slot3 GetPlayerWeaponSlot(client2);

    if(
IsValidEntity(slot1))
    {
        new 
slot1ID GetEntProp(slot1Prop_Send"m_iItemDefinitionIndex"); 
        if (
slot1ID == blockid)
        { 
            
TF2_RemoveWeaponSlot(client0);
            
hWeaponBlocked TF2Items_CreateItem(OVERRIDE_ALL);
            
TF2Items_SetClassname(hWeaponBlockedclassname);
            
TF2Items_SetItemIndex(hWeaponBlockedreplacementid);
            
TF2Items_SetQuality(hWeaponBlocked0);
            new 
iEntity TF2Items_GiveNamedItem(clienthWeaponBlocked);
            
EquipPlayerWeapon(clientiEntity);
        }
    }
    if(
IsValidEntity(slot2))
    {
        new 
slot2ID GetEntProp(slot2Prop_Send"m_iItemDefinitionIndex"); 
        if (
slot2ID == blockid)
        { 
            
TF2_RemoveWeaponSlot(client1);
            
hWeaponBlocked TF2Items_CreateItem(OVERRIDE_ALL);
            
TF2Items_SetClassname(hWeaponBlockedclassname);
            
TF2Items_SetItemIndex(hWeaponBlockedreplacementid);
            
TF2Items_SetQuality(hWeaponBlocked0);
            new 
iEntity TF2Items_GiveNamedItem(clienthWeaponBlocked);
            
EquipPlayerWeapon(clientiEntity);
        }
    }
    if(
IsValidEntity(slot3))
    {
        new 
slot3ID GetEntProp(slot3Prop_Send"m_iItemDefinitionIndex"); 
        if (
slot3ID == blockid)
        { 
            
TF2_RemoveWeaponSlot(client2);
            
hWeaponBlocked TF2Items_CreateItem(OVERRIDE_ALL);
            
TF2Items_SetClassname(hWeaponBlockedclassname);
            
TF2Items_SetItemIndex(hWeaponBlockedreplacementid);
            
TF2Items_SetQuality(hWeaponBlocked0);
            new 
iEntity TF2Items_GiveNamedItem(clienthWeaponBlocked);
            
EquipPlayerWeapon(clientiEntity);
        }
    }

I've also attached the full plugin in case it sheds some light on the problem.
Attached Files
File Type: sp Get Plugin or Get Source (WeaponBlocker.sp - 124 views - 12.3 KB)

Last edited by Astrak; 12-20-2014 at 09:42. Reason: Removed unnecessary spoiler tags.
Astrak 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 18:51.


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