Timer only works on me
#1

I made a command with timer but only works on me.....when my friend type this command nothing happens

here si my code

COMMAND
Код:
CMD:kill(playerid, params[])
{
    SetTimer("kill",10000,false);
}
TIMER
Код:
forward(playerid);
public(playerid)
{
    SetPlayerHealth(playerid, 0);
}
Reply
#2

You have to use SetTimerEx if you will create a timer with parameters. so it must be like this

pawn Код:
SetTimerEx("killit", 10000, false, "d", playerid); //put this on the command, 10000 = 10 seconds, false = don't repeat, d = represent as integer, playerid = will be the integer.

forward killit(playerid);
public killit(playerid)
{
//code here
}
Reply
#3

why are you using timer to kill him?
Reply
#4

I agree with [MM]RoXoR[FS]

U can simply use
pawn Код:
SetPlayerHealth(playerid, 0)
if you want to kill yourself
Reply
#5

Use SetTimerEx and set it to call the function SetPlayerHealth.
Creating a custom public function is not needed.

pawn Код:
CMD:kill(playerid, params[])
{
    SetTimerEx("SetPlayerHealth", 10000, false, "df", playerid, 0.0);
}
Quote:
Originally Posted by [MM]RoXoR[FS]
Посмотреть сообщение
why are you using timer to kill him?
Why not?

Meybe he did it for a reason, you never know.
Reply
#6

This is just example...i use timers on checkpoints of some jobs

But i made this command for testing timers and it's usually
Reply
#7

Quote:
Originally Posted by nikolat007
Посмотреть сообщение
This is just example...i use timers on checkpoints of some jobs

But i made this command for testing timers and it's usually
Well then the same thing just...

pawn Код:
CMD:TestCommand(playerid, params[]) {
    SetTimerEx("TestFunction", 1000, false, "d", playerid);
    return true;
}

forward TestFunction(playerid);
public TestFunction(playerid) {
    SendClientMessage(playerid, -1, "You just tested a timer that got sent to a external function in 1second.");
    return true;
}
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)