Raised This Month: $ Target: $400
 0% 

[INC] Get correct proptype


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
miniman
Senior Member
Join Date: Aug 2009
Location: Israel
Old 02-04-2010 , 02:15   [INC] Get correct proptype
Reply With Quote #1

Since I see that there is alot of problems with Props data types I have made a small include file that may help to detect a correct prop data type (Prop_Data or Prop_Send)

The Function:
PHP Code:
stock FindPropType(entity,const String:prop[],PropSend=-1,PropData=-1
Testing/Using :
PHP Code:
#include <sourcemod>
#include <sdktools>
#include <proptype>

public OnPluginStart()
{
    
RegAdminCmd("sm_test1",Test,ADMFLAG_ROOT);
}

public 
Action:Test(client,args)
{
PrintToServer("%i",FindPropType(1,"m_iMaxHealth"));    
PrintToServer("%i",FindPropType(1,"movetype"));    
PrintToServer("%i",FindPropType(-1,"movetype"));
PrintToServer("%i",FindPropType(1,"asdasfsaffa"));    
PrintToServer("%i",FindPropType(1,"m_fEffects"));    

Sever return:
PHP Code:
2
1
-1
-2


Code Itself:
PHP Code:
#define PROPTYPE_FAILED -3
#define PROPTYPE_WRONGPROP -2
#define PROPTYPE_BADENT -1
#define PROPTYPE_BOTH 0
#define PROPTYPE_SEND 1
#define PROPTYPE_DATA 2

/**
 * Finds the correct Prop type.
 *
 * @param entity     Entity that scanned for given prop.
 * @param prop      Prop to scan.
 * @param PropSend          Optional offest of Send prop if found.
 * @param PropData         Optional offest of Data prop if found.
 * @return               PropType define -3 function failed -2 wrong prop -1 bad entity 0 prop found on both 1 prop type is send 2 prop type is data
 */
stock FindPropType(entity,const String:prop[],PropSend=-1,PropData=-1)
{
    if(!
IsValidEntity(entity))
        return 
PROPTYPE_BADENT;
    new 
bool:NetClsName;
    
    
decl String:NetClass[50]="empty";
    
NetClsName=GetEntityNetClass(entity,NetClass,sizeof(NetClass))
    
PropData=FindDataMapOffs(entity,prop);
    if(
NetClsName)
    {
        
PropSend=FindSendPropOffs(NetClass,prop);
        if(
PropSend!=-1&&PropData!=-1)
            {
        return 
PROPTYPE_BOTH;
    }
        else if(
PropSend!=-1)
            return 
PROPTYPE_SEND;
        else if(
PropData!=-1)
            return 
PROPTYPE_DATA;
        else if(
PropData==-1&&PropSend==-1)
            return 
PROPTYPE_WRONGPROP;
    }
    else
    if(
PropData!=-1)
            return 
PROPTYPE_DATA;
        
return 
PROPTYPE_FAILED;


Change Log:
0.1 First release


Credits:
To me
SourceMod devs

Ask/Report/Use
Attached Files
File Type: inc proptype.inc (1.3 KB, 367 views)
miniman is offline
 


Thread Tools
Display Modes

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:18.


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