Raised This Month: $32 Target: $400
 8% 

Solved copyback for CreateGlobalForward


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
eyal282
Veteran Member
Join Date: Aug 2011
Old 01-13-2018 , 11:44   copyback for CreateGlobalForward
Reply With Quote #1

Amx Mod X provides with a feature to copy back arrays only ( I could live with that... )

Does Sourcemod provide such an option when making a global forward?

Last edited by eyal282; 01-14-2018 at 05:13.
eyal282 is offline
Fyren
FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren
Join Date: Feb 2106
Old 01-13-2018 , 17:54   Re: copyback for CreateGlobalForward
Reply With Quote #2

You tell SM to copy back arrays or not when you push them to the forward.
Fyren is offline
eyal282
Veteran Member
Join Date: Aug 2011
Old 01-14-2018 , 03:33   Re: copyback for CreateGlobalForward
Reply With Quote #3

Quote:
Originally Posted by Fyren View Post
You tell SM to copy back arrays or not when you push them to the forward.
Does it work with integers? Can you mark an array with only one cell as an integer in the callback function?

Last edited by eyal282; 01-14-2018 at 03:33.
eyal282 is offline
shavit
AlliedModders Donor
Join Date: Dec 2011
Location: Israel
Old 01-14-2018 , 04:10   Re: copyback for CreateGlobalForward
Reply With Quote #4

Quote:
Originally Posted by eyal282 View Post
Does it work with integers? Can you mark an array with only one cell as an integer in the callback function?
Yes. To mark that parameter, use the & symbol after defining its type.
__________________
retired

Last edited by shavit; 01-14-2018 at 04:10.
shavit is offline
eyal282
Veteran Member
Join Date: Aug 2011
Old 01-14-2018 , 04:35   Re: copyback for CreateGlobalForward
Reply With Quote #5

Quote:
Originally Posted by shavit View Post
Yes. To mark that parameter, use the & symbol after defining its type.
Wait, isn't Call_PushCellRef used for copyback and Call_PushCell used for regular?

Or use Call_PushCell with &? If yes, what is Call_PushCellRef?
eyal282 is offline
shavit
AlliedModders Donor
Join Date: Dec 2011
Location: Israel
Old 01-14-2018 , 04:52   Re: copyback for CreateGlobalForward
Reply With Quote #6

Quote:
Originally Posted by eyal282 View Post
Wait, isn't Call_PushCellRef used for copyback and Call_PushCell used for regular?

Or use Call_PushCell with &? If yes, what is Call_PushCellRef?
Call_PushCellRef is to push a reference.

Here's a working example:

Code:
forward Action Shavit_OnUserCmdPre(int client, int &buttons, int &impulse, float vel[3], float angles[3], TimerStatus status, int track, int style, any stylesettings[STYLESETTINGS_SIZE]);
Code:
Action result = Plugin_Continue;
Call_StartForward(gH_Forwards_OnUserCmdPre);
Call_PushCell(client);
Call_PushCellRef(buttons);
Call_PushCellRef(impulse);
Call_PushArrayEx(vel, 3, SM_PARAM_COPYBACK);
Call_PushArrayEx(angles, 3, SM_PARAM_COPYBACK);
Call_PushCell(GetTimerStatus(client));
Call_PushCell(gI_Track[client]);
Call_PushCell(gBS_Style[client]);
Call_PushArray(gA_StyleSettings[gBS_Style[client]], STYLESETTINGS_SIZE);
Call_Finish(result);

if(result != Plugin_Continue && result != Plugin_Changed)
{
	return result;
}
The cells that will get 'copybacked' are buttons, impulse, vel[3], and angles[3].

Now, if I use the Shavit_OnUserCmdPre, I can modify the variables and they will be copied back to the referenced ones.
__________________
retired
shavit 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 07:28.


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