Passing Parameters Help - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Passing Parameters Help (
/showthread.php?tid=269547)
Passing Parameters Help -
BlackKey - 16.07.2011
Hello there,
I have a question regarding parameters.
Does anyone know how to pass parameters in the same manner that SetTimerEx does without the need to use a timer?
Ex:
Код:
CMD:Example(playerid, params[])
if(!sscanf(params, "u", id))
{
SetTimerEx("ex", 1000, false, "dd", playerid, id);
}
forward ex(playerid, id);
public ex(playerid, id)
{
// whatever functions are needed for both, the id and playerid.
}
Re: Passing Parameters Help -
Kyosaur - 16.07.2011
To pass parameters, you simple use them when you're calling the function (specifying the wrong amount of parameters will result in an invalid arguments error).
You should read
THIS again. Its worth taking the time and effort to read as it teaches you the fundementals of the language.
Re: Passing Parameters Help -
BlackKey - 16.07.2011
In the example you just gave, what does the 0 stand for?
Re: Passing Parameters Help -
Kyosaur - 16.07.2011
Quote:
Originally Posted by BlackKey
In the example you just gave, what does the 0 stand for?
|
The id parameter ... i made it an actual number so it wouldn't be as confusing. I guess that didnt go so well aha.
Anyways, you should definitely read that article - there's some very useful stuff you need to learn in it.
Re: Passing Parameters Help -
BlackKey - 16.07.2011
Yeah I'm sorry. I was confused whether it meant the playerid number, false, or what you mentioned above.
I'll ask one more thing just to get this right.
In the case of let say, applying animations to two players, the player who is applying the command and another player.
Код:
CMD: animation(playerid, params[])
{
animation(playerid,id);
}
forward animation(playerid,id);
public animation(playerid, id)
{
ApplyAnimation(playerid,...);
ApplyAnimation(id,...);
return 1;
}
Would something like this apply the animation to both of these players?
Re: Passing Parameters Help -
=WoR=Varth - 17.07.2011
Yes as long as you set "id" variable. If not then it would be 0.
Re: Passing Parameters Help -
BlackKey - 17.07.2011
Okay. Thank you guys for the help. I appreciate it.