Is it possible to do this? If yes, how?
#1

Hey guys, is it possible to pass on a ID of a player towards a timer?
Example, I do /find [ID]
That command will forward the ID to a timer and it will open a textdraw, and the textdraw will automatically update with the location of the player.
Reply
#2

Yes,

how ?
pawn Код:
Command:test(playerid)
{
     SetTimerEx("OnTestExec",2000,false,"i", playerid)
}

//then later on after the timers time has passed the callback
//gets called with the playerid
forward OnTestExec(playerid);
Public OnTestExec(playerid)
{
//do what ever
}
Reply
#3

Hey thanks for replying. Is it also possible to pass on the ID of the selected player? Like

/find [PLAYERID]

Then in the timer I would be able to do
GetPlayerMoney(otherplayer) and SendClientMessage(playerid)
Reply
#4

I didn't fully understand your question, but I think you need SetTimerEx.

For example:

pawn Код:
forward x(playerid);
public x(playerid)
{
//
}

// Somewhere
SetTimerEx("x", 5000, false, "i", playerid);
SetTimerEx sets a timer for callbacks with params. (funcname, interval, loop, format, param1, param2, ...)
I don't know why the sa-mp team made 2 different functions.
Reply
#5

Quote:
Originally Posted by [GF]Sasino97
Посмотреть сообщение
I didn't fully understand your question, but I think you need SetTimerEx.

For example:

pawn Код:
forward x(playerid);
public x(playerid)
{
//
}

// Somewhere
SetTimerEx("x", 5000, false, "i", playerid);
SetTimerEx sets a timer for callbacks with params. (funcname, interval, loop, format, param1, param2, ...)
I don't know why the sa-mp team made 2 different functions.
What I want to do here is a /locate system for police. They will be able to ./locate [ID/NAME] and it will show a textdraw on their screen that will refresh itself each 5-10 seconds which is why I need a timer. BUT in that timer, I need to be able to use both my own playerid and the ID of the player that I selected.
Reply
#6

Then you need to pass two variables
pawn Код:
Command:test(playerid,params[]);
{
     SetTimerEx("OnTestExec",2000,false,"ii", playerid,selectedid);
     //u never gave your variable of how u retrieve the selected player but u will manage.
}

forward OnTestExec(playerid,selectedid);
public OnTestExec(playerid,selectedid)
{
//do what ever
}
Reply
#7

Quote:
Originally Posted by park4bmx
Посмотреть сообщение
Then you need to pass to variables
pawn Код:
Command:test(playerid,params[]);
{
     SetTimerEx("OnTestExec",2000,false,"ii", playerid,selectedid);
     //u never gave your variable of how u retrieve the selected player but u will manage.
}

forward OnTestExec(playerid,selectedid);
Public OnTestExec(playerid,selectedid)
{
//do what ever
}
Thanks buddy.
Reply


Forum Jump:


Users browsing this thread: 5 Guest(s)