Timer dont work
#8

Quote:
Originally Posted by [GF]Sasino97
Посмотреть сообщение
It happens to me too something similar:
When i am ID 0 the timer works.
Else it doesnt works.
Its a sa-mp bug.
You should use other methods.
I doubt that, again I think you're making the same mistake that I'm seeing around these forums constantly these days with people making timers. You're doing something like this:

pawn Код:
SetTimer("KillPlayer",10000,false);

public KillPlayer(playerid)
{    
    SetPlayerHealth(playerid,0);
    return 1;
}
Well of course that's only going to work for "ID 0", because the parameter playerid in the "KillPlayer" function is not being set to anything, so it's defaulting to 0. You need to pass the playerid to it in order for it to work:

pawn Код:
SetTimerEx("KillPlayer",10000,false,"i",playerid);

public KillPlayer(playerid)
{    
    SetPlayerHealth(playerid,0);
    return 1;
}
Additionally if you want to kill everyone in the server with a timer, then you would just use a loop in the function, like so:

pawn Код:
SetTimer("KillAll",10000,false);

public KillAll()
{
    for(new i; i < MAX_PLAYERS; i++) SetPlayerHealth(i,0);
    return 1;
}
This is all a bit off-topic but I hope it helps you make sense of how to use timers a little more, and about passing information to functions using SetTimerEx.
Reply


Messages In This Thread
Timer dont work - by Lorenc_ - 22.01.2011, 02:54
Re: Timer dont work - by JaTochNietDan - 22.01.2011, 03:10
Re: Timer dont work - by Lorenc_ - 22.01.2011, 03:15
Re: Timer dont work - by JaTochNietDan - 22.01.2011, 03:18
Re: Timer dont work - by Lorenc_ - 22.01.2011, 04:12
Re: Timer dont work - by JaTochNietDan - 22.01.2011, 12:30
Re: Timer dont work - by Sasino97 - 22.01.2011, 13:15
Re: Timer dont work - by JaTochNietDan - 22.01.2011, 13:18
Re: Timer dont work - by Lorenc_ - 23.01.2011, 00:21

Forum Jump:


Users browsing this thread: 1 Guest(s)