10.10.2014, 18:33
pawn Код:
CMD:goto(playerid,params[])
{
new pname[MAX_PLAYER_NAME],aname[MAX_PLAYER_NAME],string[128],id; /*Creates the player's name to teleport to, and the admin that initiated the command, and the target ID to teleport to.*/
if(!IsPlayerAdmin(playerid)) == 0) /*Checks if the player is logged into RCON. If your script has its own admin system use that.*/
{
if(sscanf(params,"u",id)) SendClientMessage(playerid, 0xAA3333AA, "/goto <id>"); /*Takes the ID you entered and makes it the "id" we defined. If no ID is entered the error message shows up*/
if(playerid == id) return SendClientMessage(playerid, 0xAA3333AA, "You can't teleport to yourself..."); /*Checks if the player id entered is not yours and if it is it shows the error message*/
else {
if(!IsPlayerConnected(id)) SendClientMessage(playerid, 0xAA3333AA, "Player is Not Online"); /*Checks if the ID entered is a player that is online in the server, otherwise sends the error message*/
else {
new Float:x,Float:y,Float:z; //Defines the x,y, and z co-ordinates of the target player
GetPlayerPos(id,Float:x,Float:y,Float:z)://Sets what the x,y, and z means
GetPlayerName(id,pname,sizeof(pname)); //Gets the name of the player that is to be teleported to
SetPlayerPos(playerid,x,y,z);//Teleports the admin to the player's x,y, and z co-ordinates we set earlier
format(string,sizeof(string),"Teleported to %s!",pname);//Shows the admin they teleported to the player
SendClientMessage(playerid, 0xAA333AA, string);//^^
}
}
}
else return 0; //Sends the "SERVER: Unknown command" if the person wanting to teleport isn't an admin
return 1;
}