Raised This Month: $51 Target: $400
 12% 

Script Ignores check after saying checking for Soldier


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Hostile_Badger
Junior Member
Join Date: Jul 2022
Old 08-06-2023 , 16:47   Script Ignores check after saying checking for Soldier
Reply With Quote #1

I have a script here making a check, if the class is soldier and has a stock melee active (shovel or reskins) It will run the plugin. But for some reason it ignores the check after soldier and applies to every weapon. I'm not sure why.

Check here and also in an .sp

if (TF2_GetPlayerClass(client) != TFClass_Soldier && TF2_GetItemDefinitionIndexSafe(hMelee) != 6 && TF2_GetItemDefinitionIndexSafe(hMelee) != 196 && TF2_GetItemDefinitionIndexSafe(hMelee) != 264 && TF2_GetItemDefinitionIndexSafe(hMelee) != 474 && TF2_GetItemDefinitionIndexSafe(hMelee) != 880 && TF2_GetItemDefinitionIndexSafe(hMelee) != 939 && TF2_GetItemDefinitionIndexSafe(hMelee) != 954 && TF2_GetItemDefinitionIndexSafe(hMelee) != 1013 && TF2_GetItemDefinitionIndexSafe(hMelee) != 1123 && TF2_GetItemDefinitionIndexSafe(hMelee) != 1127) {
return Plugin_Continue;
}
Attached Files
File Type: txt shovel_plugin.txt (918 Bytes, 15 views)

Last edited by Hostile_Badger; 08-06-2023 at 16:47. Reason: Forgot to add file
Hostile_Badger is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 08-06-2023 , 17:43   Re: Script Ignores check after saying checking for Soldier
Reply With Quote #2

Since you're posting in the AMX Mod X section, I'm not sure what most of these things mean (because it's SourceMod) but it can be made much more efficient and maintainable:

PHP Code:
public Action TF2_OnTakeHealthGetMultiplier(int clientfloat &flMultiplier)
{
    if( 
TF2_GetPlayerClass(client) != TFClass_Soldier )
    {
        
int hMelee GetPlayerWeaponSlot(clientTFWeaponSlot_Melee);
        
int ItemIndex TF2_GetItemDefinitionIndexSafe(hMelee);
        switch( 
ItemIndex )
        {
            case: 
,196 ,264 ,474 ,880 ,939 ,954 ,1013 ,1123 ,1127
            
{
                
// Do nothing
            
}
            default:
            {
                
// ItemIndex isn't one of the values above
                
return Plugin_Continue;
            }
        }
    } 
Maybe this will help you solve your issues, being able to look at it different can sometimes help. Note that I don't do any SourceMod programming so I don't know if the syntax above is actually correct.
__________________

Last edited by fysiks; 08-06-2023 at 17:43.
fysiks 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 01:38.


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