[CheckPoint]Cmd to find players -
waim - 22.08.2012
Hii Everybody, I need a zcmd or cmd to find the location of player by typing for ex : /findp and /cancelfind to cancel the checkpoint .. Thanks !
Re: [CheckPoint]Cmd to find players -
Arca - 22.08.2012
This is not a request section although I should say that this could be done using the following functions:
GetPlayerPos
SetPlayerCheckpoint
Re: [CheckPoint]Cmd to find players -
ThePhenix - 22.08.2012
Try it:
pawn Код:
CMD:findp(playerid, params[])
{
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
SendClientMessage(playerid, green, "This player is in %f, %f, %f position");
return SendClientMessage(playerid, 0x0000B4FF, "You have found the player position");
}
Re: [CheckPoint]Cmd to find players -
clarencecuzz - 22.08.2012
That's obviously not what he's asking for...
If you're using a filterscript, OnFilterScriptInit, Gamemode, etc.
pawn Код:
#include <a_samp>
#include <zcmd>
#include <sscanf2>
new PlayerTracking[MAX_PLAYERS];
public OnFilterScriptInit() //Or OnGameModeInit() if you're using a gamemode.
{
SetTimer("TrackPlayer", 2000, true);
return 1;
}
public OnPlayerConnect(playerid)
{
PlayerTracking[playerid] = -1; //-1 so it won't get mixed up with existant Player IDs.
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
for(new i = 0; i < MAX_PLAYERS; i++) //Alternatively, you can use foreach here, as it is more efficient.
{
if(IsPlayerConnected(i))
{
if(i != playerid)
{
if(PlayerTracking[i] == playerid)
{
SendClientMessage(i, 0xFF0000FF, "The Player You Were Tracking Has Disconnected From The Server.");
PlayerTracking[i] = -1;
}
}
}
}
return 1;
}
CMD:findp(playerid,params[])
{
new id;
if(sscanf(params,"u",playerid)) return SendClientMessage(playerid, 0xFF0000FF, "SYNTAX ERROR: {00FF00}/FINDP {FFFF00}<PlayerID>");
if(id == playerid) return SendClientMessage(playerid, 0xFF0000FF, "You Can't Track Yourself!");
if(!IsPlayerConnected(id)) return SendClientMessage(playerid, 0xFF0000FF, "This Player Is Not Connected.");
if(PlayerTracking[playerid] == id) return SendClientMessage(playerid, 0xFF0000FF, "You Are Already Tracking This Player!");
new string[45];
new name[MAX_PLAYER_NAME];
GetPlayerName(id, name, MAX_PLAYER_NAME);
format(string,sizeof(string),"You Are Now Tracking %s (%d).",name, id);
PlayerTracking[playerid] = id;
return 1;
}
CMD:cancelfind(playerid,params[])
{
if(PlayerTracking[playerid] == -1) return SendClientMessage(playerid, 0xFF0000FF, "You Are Not Tracking Anyone!");
SendClientMessage(playerid, 0xFFFF00FF, "You Are No Longer Tracking A Player.");
PlayerTracking[playerid] = -1;
return 1;
}
public OnPlayerEnterCheckpoint(playerid)
{
DisablePlayerCheckpoint(playerid);
SendClientMessage(playerid, 0xFFFF00FF, "You Have Reached Your Tracked Player's Location.");
PlayerTracking[playerid] = -1;
return 1;
}
forward TrackPlayer(playerid);
public TrackPlayer(playerid)
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(PlayerTracking[i] != -1)
{
new Float:X, Float:Y, Float:Z;
GetPlayerPos(PlayerTracking[i],X,Y,Z);
DisablePlayerCheckpoint(i);
SetPlayerCheckpoint(i, X, Y, Z, 5);
}
}
}
return 1;
}
This code SHOULD work. Note: Untested.
Foreach include is RECOMMENDED.
Re : [CheckPoint]Cmd to find players -
waim - 22.08.2012
clarencecuzz // Well it works ! But When I type for ex /findp 0 Id = 0 For Player The Checkpoint doesn't appear but when I type /find p 1 ID = 1 me the Checkpont apprears on the player ..
Re: [CheckPoint]Cmd to find players -
RedJohn - 22.08.2012
Try to search on the internet!
Re: [CheckPoint]Cmd to find players -
clarencecuzz - 23.08.2012
I already have if(id == playerid) in there.
****** Search sscanf ID 0 problem, I've encountered this before, just search for any fixes.