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

[Questions] cs 1.6 functions to sourcemod functions


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Elitcky
AlliedModders Donor
Join Date: Jun 2016
Location: Antofagasta, Chile
Old 06-29-2016 , 17:41   [Questions] cs 1.6 functions to sourcemod functions
Reply With Quote #1

Hey guys! well im trying to do like a same plugin of cs1.6 but for sourcemod, changing his functions natives and more

i have some question from 1.6 to sm like this
is the same if i use from cs 1.6
PHP Code:
#define fm_get_user_money(%1)    get_pdata_int( %1, 115 ) 
and in sourcemod i define it like
PHP Code:
#define get_user_money(%1)    int GetEntData( %1, 115) 
thanks! im going to post more question in here, and the people who can help me is going to have credits on what im trying to do
__________________
Elitcky is offline
KissLick
Veteran Member
Join Date: Nov 2012
Location: void
Old 06-29-2016 , 17:43   Re: [Questions] cs 1.6 functions to sourcemod functions
Reply With Quote #2

Please don't use preprocessor macros
__________________
Plugins: TeamGames
Includes: Menu stocks, ColorVariables, DownloadTableConfig

> No help through PM, make a topic.
KissLick is offline
Elitcky
AlliedModders Donor
Join Date: Jun 2016
Location: Antofagasta, Chile
Old 06-29-2016 , 18:44   Re: [Questions] cs 1.6 functions to sourcemod functions
Reply With Quote #3

Quote:
Originally Posted by KissLick View Post
Please don't use preprocessor macros
and what should i use ?
__________________
Elitcky is offline
hlstriker
Green Gaben
Join Date: Mar 2006
Location: OH-IO!
Old 07-02-2016 , 04:18   Re: [Questions] cs 1.6 functions to sourcemod functions
Reply With Quote #4

Quote:
Originally Posted by KissLick View Post
Please don't use preprocessor macros
For aliasing datamap and sendprop functions I really don't see the problem.

To answer the question you will mostly be using one of the GetEntProp* functions which take Prop_Send or Prop_Data as it's second argument.

To get a list of properties for each prop type you can use the following console commands which outputs a file in your servers root directory and contains all of the properties.
Prop_Data properties: sm_dump_datamaps datamaps.txt
Prop_Send properties: sm_dump_netprops netprops.txt

Really the only time I ever used GetEntData was back before GetEntProp existed or before you could specify an array index within GetEntProp.

This is the new macro you would want to use:
PHP Code:
#define get_user_money(%1)    GetEntProp(%1, Prop_Send, "m_iAccount") 
hlstriker is offline
ddhoward
Veteran Member
Join Date: May 2012
Location: California
Old 06-29-2016 , 19:06   Re: [Questions] cs 1.6 functions to sourcemod functions
Reply With Quote #5

Either actual custom functions, or just use the functions that the macros replace.
__________________

Last edited by ddhoward; 06-29-2016 at 19:18.
ddhoward is offline
ddhoward
Veteran Member
Join Date: May 2012
Location: California
Old 07-02-2016 , 14:48   Re: [Questions] cs 1.6 functions to sourcemod functions
Reply With Quote #6

PHP Code:
int get_user_money(int client) {
    return 
GetEntProp(clientProp_Send"m_iAccount");

I don't remember where I read it, but Sourcepawn's support for preprocessor macros of this type may be going away, so we should avoid using them in plugins.

EDIT: Found it
https://forums.alliedmods.net/showth...77#post2228277
__________________

Last edited by ddhoward; 07-02-2016 at 14:56.
ddhoward is offline
KissLick
Veteran Member
Join Date: Nov 2012
Location: void
Old 07-03-2016 , 14:08   Re: [Questions] cs 1.6 functions to sourcemod functions
Reply With Quote #7

Quote:
Originally Posted by ddhoward View Post
PHP Code:
int get_user_money(int client) {
    return 
GetEntProp(clientProp_Send"m_iAccount");

I don't remember where I read it, but Sourcepawn's support for preprocessor macros of this type may be going away, so we should avoid using them in plugins.

EDIT: Found it
https://forums.alliedmods.net/showth...77#post2228277
+1
__________________
Plugins: TeamGames
Includes: Menu stocks, ColorVariables, DownloadTableConfig

> No help through PM, make a topic.
KissLick is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 07-03-2016 , 14:27   Re: [Questions] cs 1.6 functions to sourcemod functions
Reply With Quote #8

But SourcePawn doesn't inline short functions, does it? There would be some function call overhead in case it doesn't. Well, it should make no difference unless used in a callback that's called every frame or more frequently.
klippy is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 07-03-2016 , 14:32   Re: [Questions] cs 1.6 functions to sourcemod functions
Reply With Quote #9

Frame creation overhead is absolutely not worth considering.
__________________
asherkin is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 07-03-2016 , 14:54   Re: [Questions] cs 1.6 functions to sourcemod functions
Reply With Quote #10

Well, true. However, function inlining would be cool to have.
klippy 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 10:25.


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