Raised This Month: $ Target: $400
 0% 

[INC] Get correct proptype


Post New Thread Reply   
 
Thread Tools Display Modes
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
berni
SourceMod Plugin Approver
Join Date: May 2007
Location: Austria
Old 02-04-2010 , 19:55   Re: [INC] Get correct proptype
Reply With Quote #2

I dont really see the sense of this, as you can just dump all network or datamap -properties to files, and look in there.
I'm currently making a searchable webbased database out of this.
__________________
Why reinvent the wheel ? Download smlib with over 350 useful functions.

When people ask me "Plz" just because it's shorter than "Please" I feel perfectly justified to answer "No" because it's shorter than "Yes"
powered by Core i7 3770k | 32GB DDR3 1886Mhz | 2x Vertex4 SSD Raid0
berni is offline
miniman
Senior Member
Join Date: Aug 2009
Location: Israel
Old 02-04-2010 , 23:57   Re: [INC] Get correct proptype
Reply With Quote #3

Quote:
Originally Posted by berni View Post
I dont really see the sense of this, as you can just dump all network or datamap -properties to files, and look in there.
I'm currently making a searchable webbased database out of this.
I just tought about building build mod for admins that admin can modify props by itself .
but I see sometimes people just want to make some mods for all entitys and they just dont know how to check what entity is based on server side and what on client side so i made small check function

Last edited by miniman; 02-05-2010 at 00:02.
miniman is offline
berni
SourceMod Plugin Approver
Join Date: May 2007
Location: Austria
Old 02-05-2010 , 05:54   Re: [INC] Get correct proptype
Reply With Quote #4

The datamap and the Sendmap don't have anything todo wether it's serverside or not, the datamap values are just values only the server needs to know about, and the send properties get synced with the client.
And usually when you know the name of a property, you also know where it is stored in, but usually the datamap contains every property that the sendmap contains too.
__________________
Why reinvent the wheel ? Download smlib with over 350 useful functions.

When people ask me "Plz" just because it's shorter than "Please" I feel perfectly justified to answer "No" because it's shorter than "Yes"
powered by Core i7 3770k | 32GB DDR3 1886Mhz | 2x Vertex4 SSD Raid0
berni is offline
Reply


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