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

Call an Action function from another function


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
pillowCloud
Member
Join Date: Aug 2015
Location: AlliedModders
Old 05-27-2019 , 16:08   Call an Action function from another function
Reply With Quote #1

hi,

i want to do something like this:

PHP Code:

public int Native_Give_Points(Handle:pluginint numParams)
{
    
int arg1// id of the function caller
    
char arg2[32]; // give points to this name
    
int arg3// amount of points

    
arg1 GetNativeCell(1); // get id of the function caller
    
GetNativeString(2arg2sizeof(arg2)); // get give points to this name
    
arg3 GetNativeCell(3); // get amount of points

    
GivePoints(arg1arg2arg3); // call function like this
}

public 
Action GivePoints(int clientint args)
{
    
// do stuff

but it says: "error 035: argument type mismatch (argument 2)"


how i can call can GivePoints with some known parameters?

btw, i'm newbie
pillowCloud is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 05-27-2019 , 16:27   Re: Call an Action function from another function
Reply With Quote #2

If GivePoints is from a command:

- Make it OnGivePoints
- Make another function GivePoints with the correct parameters
- From OnGivePoints grab your parameters and send them through GivePoints
__________________
Neuro Toxin is offline
pillowCloud
Member
Join Date: Aug 2015
Location: AlliedModders
Old 05-27-2019 , 16:39   Re: Call an Action function from another function
Reply With Quote #3

Quote:
Originally Posted by Neuro Toxin View Post
If GivePoints is from a command:

- Make it OnGivePoints
- Make another function GivePoints with the correct parameters
- From OnGivePoints grab your parameters and send them through GivePoints
oh feel bad for not thinking about it

btw, there is no way to call an Action function if needed?
pillowCloud is offline
impossible_cc
Senior Member
Join Date: Sep 2018
Location: Ukraine
Old 05-27-2019 , 17:03   Re: Call an Action function from another function
Reply With Quote #4

Action is just a type of returning value.
You should use predetermined amount of parameters, or if you dont know exactly how many parameters will be passed, use array as param.
__________________
impossible_cc is offline
impossible_cc
Senior Member
Join Date: Sep 2018
Location: Ukraine
Old 05-27-2019 , 17:05   Re: Call an Action function from another function
Reply With Quote #5

PHP Code:

public int Native_Give_Points(Handle:pluginint numParams)
{
    
int arg1// id of the function caller
    
char arg2[32]; // give points to this name
    
int arg3// amount of points

    
arg1 GetNativeCell(1); // get id of the function caller
    
GetNativeString(2arg2sizeof(arg2)); // get give points to this name
    
arg3 GetNativeCell(3); // get amount of points

    
GivePoints(arg1arg2arg3); // call function like this
}

public 
Action GivePoints(int arg1char arg2[32], int arg3)
{
    
// do stuff

__________________

Last edited by impossible_cc; 05-27-2019 at 17:06.
impossible_cc is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 05-27-2019 , 18:33   Re: Call an Action function from another function
Reply With Quote #6

Just don't, do what Neuro Toxin said.
__________________
klippy is offline
pillowCloud
Member
Join Date: Aug 2015
Location: AlliedModders
Old 05-27-2019 , 23:53   Re: Call an Action function from another function
Reply With Quote #7

Quote:
Originally Posted by impossible_cc View Post
Action is just a type of returning value.
You should use predetermined amount of parameters, or if you dont know exactly how many parameters will be passed, use array as param.
Quote:
Originally Posted by KliPPy View Post
Just don't, do what Neuro Toxin said.
fine, thank you all!
pillowCloud is offline
Reply



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 17:34.


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