Passing Parameters Help
#1

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.
}
Reply
#2

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).

Код:
ex(playerid, 0);
You should read THIS again. Its worth taking the time and effort to read as it teaches you the fundementals of the language.
Reply
#3

In the example you just gave, what does the 0 stand for?
Reply
#4

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.
Reply
#5

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?
Reply
#6

Yes as long as you set "id" variable. If not then it would be 0.
Reply
#7

Okay. Thank you guys for the help. I appreciate it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)