[Help] /goto and /nogoto
#1

How to make a /goto and /nogoto
Reply
#2

pawn Код:
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;
}
Reply
#3

What does /nogoto do?
Reply
#4

disable player teleport (nogoto)
Reply
#5

pawn Код:
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;
}
Reply
#6

Код:
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;
}
Reply
#7

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, Float:y, Float:z;
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: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;
}



upload pics
Reply
#8

+ rep ?? not forcing
Reply
#9

Line 51 - 54 - 61: Add "new id;" above the sscanf line.
Line 65 - 70: You didn't make a new string and format it.
Line 15: You don't have new or enum pInfo.
Line 175: You have new PlayerInfo but you never used it. You can delete it, comment it or add stock after new.
Reply
#10

I do not know if my little simple way how to fix
my skype:gazara_21993



print screen windows
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)