View Single Post
Afronanny
Veteran Member
Join Date: Aug 2009
Old 03-08-2013 , 09:04   Re: [TF2] Increase Max Health of Player?
Reply With Quote #26

Quote:
Originally Posted by Oshizu View Post
I'm trying to add attribute to player using signature
CTFPlayer::AddPlayerAttribute(CEconItemAttrib ute *)
but i'm not sure what value i'm suppose to add or how it should look like
PHP Code:
#include <sourcemod>
#include <sdktools>
 
new Handle:hGameConf;
new 
Handle:hGiveAttribute;

public 
Plugin:myinfo =
{
    
name "[TF2] Attribute Add",
    
author "Oshizu",
    
description "Test",
    
version "0.1d",
    
url "none"
};
 
public 
OnPluginStart()
{

    
hGameConf LoadGameConfigFile("oshizu.attribute");
    
StartPrepSDKCall(SDKCall_Player);
    
PrepSDKCall_SetFromConf(hGameConfSDKConf_Signature"CTFPlayer::AddPlayerAttribute");
    
PrepSDKCall_AddParameter(SDKType_PlainOldDataSDKPass_Plain);
    
hGiveAttribute EndPrepSDKCall();
 
    
RegConsoleCmd("sm_maxhealth"SetMaxHealth);
}

public 
Action:SetMaxHealth(clientargs)
{
 
SDKCall(hGiveAttributeclient"26 500.0");

Gamedata
PHP Code:
"Games"
{
    
/* Team Fortress 2 */
    
"tf"
    
{
        
"Signatures"
        
{
            
"CTFPlayer::AddPlayerAttribute"
            
{
                
"library"            "server"
                "windows"            "\x55\x8B\xEC\x8B\x45\x08\x85\xC0\x74\x2A\x50\x81\xC1\x04\x0A\x00\x00"
                "linux" "@_ZN9CTFPlayer18AddPlayerAttributeEP18CEconItemAttribute"
                "mac" "@_ZN9CTFPlayer18AddPlayerAttributeEP18CEconItemAttribute"
            
}
        }
    }

Seems to crash my server. Probatly line 'SDKCall(hGiveAttribute, client, "26 500.0");' is incorrectly made.
You can't use that function in an SDKCall. If you look at the linux symbol, the function prototype is actually "CTFPlayer::AddPlayerAttribute(CEconItemAttri bute *)"

The reason that code is crashing your server is because you're trying to pass a string when the function is expecting a CEconItemAttribute* as the argument, which you cannot create in SourcePawn.

Last edited by Afronanny; 03-08-2013 at 09:05.
Afronanny is offline