04.08.2014, 06:31
How to make a /goto and /nogoto
CMD:goto(playerid,params[])
{
new teleid;
if(sscanf(params,"u",teleid)) return SendClientMessage(playerid, red, "Usage:/goto [playerid]");
if(!IsPlayerConnected(teleid)) return SendClientMessage(playerid, red, "Player is not connected");
if(teleid == INVALID_PLAYER_ID) return SendClientMessage(playerid, red, "This isn't a valid player ID");
new Float:telex,Float:teley,Float:telez,int;
GetPlayerPos(teleid,telex,teley,telez);
int = GetPlayerInterior(teleid);
SetPlayerPos(playerid,telex,teley,telez+1);
SetPlayerInterior(playerid,int);
return 1;
}
new bool:Goto_Disabled[MAX_PLAYERS];
public OnPlayerDisconnect(playerid, reason)
{
Goto_Disabled[playerid] = false;
return 1;
}
CMD:goto(playerid, params[])
{
if (sscanf(params, "u", id))
return SendClientMessage(playerid, -1, "Usage: /goto [id/name]");
if (!IsPlayerConnected(id))
return SendClientMessage(playerid, -1, "Error: Player is not connected.");
if (Goto_Disabled[playerid] == true)
return SendClientMessage(playerid, -1, "Error: Player does not want anyone to teleport to him.");
new Float:x, Float:y, Float:z;
GetPlayerPos(id, x, y, z);
SetPlayerInterior(playerid, GetPlayerInterior(id));
SetPlayerPos(playerid, x, y, z);
return 1;
}
CMD:nogoto(playerid, params[])
{
if (Goto_Disabled[playerid] == false)
{
SendClientMessage(playerid, -1, "Players are now unable to teleport to you.");
Goto_Disabled[playerid] = true;
}
else if (Goto_Disabled[playerid] == true)
{
SendClientMessage(playerid, -1, "Players are now able to teleport to you.");
Goto_Disabled[playerid] = false;
}
return 1;
}
CMD:goto (playerid, params[]) { new Float:x, Float:y, Float:z ; new id, string[128]; if (sscanf(params,"u",id)) return SendClientMessage (playerid,0x6FFF00FF,"{F07F1D}USAGE: {BBFF00}/goto <ID>"); if (id == INVALID_PLAYER_ID) return SendClientMessage(playerid,-1,"{FA002E}ERROR: {C7BDBF}Invalid player ID!"); if ( PlayerInfo[playerid][inDM] == 1) return SendClientMessage(playerid, -1, ""RED"ERROR: "GREY"You cannot use this command here! Please type /leave to exit!" ); if (PlayerInfo[id][Goto] == 1) { format(string, sizeof(string), "{FA002E}ERROR: {C7BDBF}%s(%d) has teleport disabled!", GetName(id), id); SendClientMessage( playerid, -1, string ); return 1; } else format(string,sizeof(string),"{D9F238}You have teleported to {%06x}%s(%d){D9F238}!", (GetPlayerColor(id) >>> 8), GetName(id), id ); GetPlayerPos(id,x,y,z); if (IsPlayerInAnyVehicle(playerid)) { SetVehiclePos(GetPlayerVehicleID(playerid), x, y, z + 1.0); SendClientMessage(playerid, -1, string); } else { SetPlayerPos(playerid, x, y, z + 1.0); SendClientMessage(playerid,-1,string); } return 1; } CMD:enablegoto (playerid) return cmd_allowgoto (playerid); CMD:allowgoto (playerid) { if (PlayerInfo[playerid][Goto] == 0) return SendClientMessage( playerid, -1, "{FA002E}ERROR: {C7BDBF}You already have your teleport enabled!"); else PlayerInfo[playerid][Goto] = 0; SendClientMessage( playerid, -1, ""ORANGE"- Teleport - "GREEN"You have enabled your teleport!" ); return 1; } CMD:disablegoto (playerid) return cmd_disallowgoto (playerid); CMD:disallowgoto (playerid) { if (PlayerInfo[playerid][Goto] == 1) return SendClientMessage( playerid, -1, "{FA002E}ERROR: {C7BDBF}You already have your teleport disabled!"); else PlayerInfo[playerid][Goto] = 1; SendClientMessage( playerid, -1, ""ORANGE"- Teleport - "RED"You have disabled your teleport!" ); return 1; }