Help checkpoint -
SkizzoTrick - 19.11.2010
How to set a checkpoint to follow a player?
Re: Help checkpoint -
MadeMan - 19.11.2010
Use a timer.
https://sampwiki.blast.hk/wiki/SetTimer
Re: Help checkpoint -
SkizzoTrick - 19.11.2010
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?
Re: Help checkpoint -
SkizzoTrick - 19.11.2010
Look,this is the code
PHP код:
if (strcmp(cmd, "/tracker", true) == 0)
{
new Float:x, Float:y, Float:z;
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_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(playerid, 15, x, y, z))
{
SendClientMessage(playerid, COLOR_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;
}
Re: Help checkpoint -
lavamike - 19.11.2010
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
}
Re: Help checkpoint -
MadeMan - 19.11.2010
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);
}
}
}
Re: Help checkpoint -
SkizzoTrick - 19.11.2010
Thanks man,i didn't knew about the repetition,thanks alot!
Re: Help checkpoint -
WillyP - 19.11.2010
Using PHP tags are for noobs.
Re: Help checkpoint -
MadeMan - 19.11.2010
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);
}
Re: Help checkpoint -
SkizzoTrick - 19.11.2010
This is what ive been searching for,thanks alot Mad