23.06.2016, 14:14
pawn Код:
new lastTPTime[MAX_PLAYERS];
public OnPlayerConnect(playerid)
{
lastTPTime[playerid] = 0;
return 1;
}
CMD:tp(playerid, params[])
{
if(!IsZombieDigger(playerid))return SendClientMessage(playerid, -1, "You're not the required class of Zombie to do this.");
if(gettime() < lastTPTime[playerid])return SendClientMessage(playerid, -1, "You can't TP yet.");
new id, Float:x, Float:y, Float:z;
if(sscanf(params, "u", id))return SendClientMessage(playerid, -1, "Usage: /tp [playerid/name] - This will TP you to a human.");
{
if(!IsPlayerConnected(id))return SendClientMessage(playerid, -1, "That player isn't connected.");
if(!IsHuman(id))return SendClientMessage(playerid, -1, "That player isn't a Human.");
GetPlayerPos(id, x, y, z);
SetPlayerPos(playerid, x, y-2.0, z);
SendClientMessage(playerid, -1, "You have teleported to a human!");
lastTPTime[playerid] = (gettime() + 120);
}
return 1;
}
It's not to the nearest player, but to a player of choice. A bit of research can get the closest player ID.