Updating a players pos with timer
#1

Okay, so I want to make a /take command for a restrained player, and every 100-500ms it will set the players pos to the police officer using /take...

and i get him to teleport, but the timer doesn't keep repeating the teleport function but repeats the command if that makes sense... anyone have any idea of how i can do this, code with comments is good, but if you tell me everything i need to know to make it, that's great.

Thanks in advance.
Reply
#2

can u tell more clearly what u want
Reply
#3

https://sampwiki.blast.hk/wiki/SetTimer

or

https://sampwiki.blast.hk/wiki/SetTimerEx

and

https://sampwiki.blast.hk/wiki/KillTimer

look at the "repeat" parameter, set it to true.

then later on kill the timer so it won't go on indefinitely.
Reply
#4

Also don't forget to set a variable to the timer for properly using KillTimer

For example

PHP код:

new ptimer// ptimer like pos timer

public UpdatePlayerPos(playerid)
{
    new 
Float:xFloat:yFloat:z;
    
GetPlayerPos(playeridxyz);
    
// Don't know what you wanna do, so i'll use it with SetPlayerCheckpoint
    
for(new 0MAX_PLAYERS;p++)
    {
        if(
== playerid) continue;
        else return 
SetPlayerCheckpoint(ixyz5.0);
    }
// In ur command

ptimer SetTimerEx("UpdatePlayerPos"500true"d"playerid);

// In the command to stop

if(strcmp(cmdtext"/stoptimer"true) == 0)
{
     
KillTimer(ptimer);
     print(
"Timer killed");
     return 
1;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)