Help checkpoint
#1

How to set a checkpoint to follow a player?
Reply
#2

Use a timer.

https://sampwiki.blast.hk/wiki/SetTimer
Reply
#3

Ok,i thought to use that but how to update it?i mean i put

SetTimer(bbb,1000..)

Public bbb
{
Getplayerpos(i,x,y,z)
SetPlayerCheckpoint(playerid,x,y,z)
return 1;
}

And then?
Reply
#4

Look,this is the code

PHP код:
        if (strcmp(cmd"/tracker"true) == 0)
        {
        new 
Float:xFloat:yFloat:z;
                    
tmp strtok(cmdtextidx);
                    if(!
strlen(tmp))
                    {
                        
SendClientMessage(playeridCOLOR_GRAD2"USAGE: /tracker [playerid/PartOfName]");
                        return 
1;
                    }
                       
giveplayerid ReturnUser(tmp);
                    if(
PlayerInfo[playerid][pJob] == 1)
                        {
                            
GetPlayerPos(giveplayerid,x,y,z);
                            if(
PlayerInfo[playerid][pJustAttachedMole] == 0)
                                        {
                                        if(!
IsPlayerInRangeOfPoint(playerid15xyz))
                                        {
                                            
SendClientMessage(playeridCOLOR_GRAD1"** Player is not near you!");
                                            return 
1;
                                        }
                                        
SetPlayerCheckpoint(playerid,x,y,z,5.0);
                                        
GameTextForPlayer(playerid,"~b~Tracker Attached to ~n~~r~suspect",5000,5);
                                        
PlayerInfo[playerid][pJustAttachedMole] = 1;
                                        
SendClientMessage(playerid,COLOR_RED,"|______________Laptop Information________________|");
                                        
SendClientMessage(playerid,COLOR_RED,"Tracker attatched,your tracking your suspect!");
                                        
SendClientMessage(playerid,COLOR_RED,"Type /killtracker to deatatch it!");
                                        }
                            else
                            {
                            
SendClientMessage(playerid,COLOR_YELLOW,"You already have an attached tracker,type /killtracker to deattatch it!");
                            }
                        }
                    else
                    {
                    
SendClientMessage(playerid,COLOR_RED,"You need to be a detective for this job!");
                    }
                    return 
1;
                } 
Reply
#5

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

SetTimer("Public Function Here", time(ms), repeating(1 or 0));
so example is:

SetTimer("bbb", 1000, 1);

public bbb()
{
// Do stuffs
}
Reply
#6

pawn Код:
new CPTimer[MAX_PLAYERS];
To start following the player:

pawn Код:
CPTimer[playerid] = SetTimerEx("UpdateCP", 1000, true, "i", playerid);
To stop following the player:

pawn Код:
KillTimer(CPTimer[playerid]);
pawn Код:
forward UpdateCP(playerid);
public UpdateCP(playerid)
{
    new Float:pos[3];
    GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
    for(new i=0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            SetPlayerCheckpoint(i, pos[0], pos[1], pos[2], 3.0);
        }
    }
}
Reply
#7

Thanks man,i didn't knew about the repetition,thanks alot!
Reply
#8

Using PHP tags are for noobs.
Reply
#9

Or if you want to show the checkpoint to only 1 player, then:

pawn Код:
CPTimer[playerid] = SetTimerEx("UpdateCP", 1000, true, "ii", playerid, giveplayerid);
pawn Код:
forward UpdateCP(playerid, giveplayerid);
public UpdateCP(playerid, giveplayerid)
{
    new Float:pos[3];
    GetPlayerPos(giveplayerid, pos[0], pos[1], pos[2]);
    SetPlayerCheckpoint(playerid, pos[0], pos[1], pos[2], 3.0);
}
Reply
#10

This is what ive been searching for,thanks alot Mad
Reply


Forum Jump:


Users browsing this thread: 6 Guest(s)