[Help] Goto XYZ
#1

I need help making a /goto XYZ

or a new cmd called
/gotoco / /gotoxyz

I got this command what is my /goto cmd, but when I try to add it to be able to teleport by cords, it bugs. If anyone could help me, it would be great.

Код:
CMD:goto(playerid, params[])
{
	static
	    id,
	    type[24],
		string[64];

	if (PlayerData[playerid][pAdmin] < 1)
	    return SendErrorMessage(playerid, "You don't have permission to use this command.");

	if (sscanf(params, "u", id))
 	{
	 	SendSyntaxMessage(playerid, "/goto [player or name]");
		SendClientMessage(playerid, COLOR_YELLOW, "[NAMES]:{FFFFFF} spawn, prison, house, business, entrance, job, gate, interior, billboard");
		return 1;
	}
    if (id == INVALID_PLAYER_ID)
	{
	    if (sscanf(params, "s[24]S()[64]", type, string))
		{
		    SendSyntaxMessage(playerid, "/goto [player or name]");
			SendClientMessage(playerid, COLOR_YELLOW, "[NAMES]:{FFFFFF} spawn, prison, house, business, entrance, job, gate, interior, billboard");
			return 1;
	    }
	    if (!strcmp(type, "spawn", true)) {
	        SetDefaultSpawn(playerid);

	        return SendServerMessage(playerid, "You have teleported to the default spawn.");
		}
		else if (!strcmp(type, "prison", true))
		{
	        SetPlayerPos(playerid, 283.5930, 1413.3511, 10.4078);
	        SetPlayerFacingAngle(playerid, 180.0000);

	        SetPlayerInterior(playerid, 0);
	        SetPlayerVirtualWorld(playerid, 0);

	        return SendServerMessage(playerid, "You have teleported to the prison facility.");
		}
		//
		else if (!strcmp(type, "billboard", true))
		{
		    if (sscanf(string, "d", id))
		        return SendSyntaxMessage(playerid, "/goto [billboard] [billboard ID]");

			if ((id < 0 || id >= MAX_BILLBOARDS) || !BillBoardData[id][bbExists])
			    return SendErrorMessage(playerid, "You have specified an invalid billboard ID.");

		    SetPlayerPos(playerid, BillBoardData[id][bbPos][0], BillBoardData[id][bbPos][1], BillBoardData[id][bbPos][2]);
		    SendServerMessage(playerid, "You have teleported to billboard ID: %d.", id);
		    return 1;
		}
		//
		else if (!strcmp(type, "house", true))
		{
		    if (sscanf(string, "d", id))
		        return SendSyntaxMessage(playerid, "/goto [house] [house ID]");

			if ((id < 0 || id >= MAX_HOUSES) || !HouseData[id][houseExists])
			    return SendErrorMessage(playerid, "You have specified an invalid house ID.");

		    SetPlayerPos(playerid, HouseData[id][housePos][0], HouseData[id][housePos][1], HouseData[id][housePos][2]);
		    SetPlayerInterior(playerid, HouseData[id][houseExterior]);

			SetPlayerVirtualWorld(playerid, HouseData[id][houseExteriorVW]);
		    SendServerMessage(playerid, "You have teleported to house ID: %d.", id);
		    return 1;
		}
		else if (!strcmp(type, "business", true))
		{
		    if (sscanf(string, "d", id))
		        return SendSyntaxMessage(playerid, "/goto [business] [business ID]");

			if ((id < 0 || id >= MAX_BUSINESSES) || !BusinessData[id][bizExists])
			    return SendErrorMessage(playerid, "You have specified an invalid business ID.");

		    SetPlayerPos(playerid, BusinessData[id][bizPos][0], BusinessData[id][bizPos][1], BusinessData[id][bizPos][2]);
		    SetPlayerInterior(playerid, BusinessData[id][bizExterior]);

			SetPlayerVirtualWorld(playerid, BusinessData[id][bizExteriorVW]);
		    SendServerMessage(playerid, "You have teleported to business ID: %d.", id);
		    return 1;
		}
		else if (!strcmp(type, "entrance", true))
		{
		    if (sscanf(string, "d", id))
		        return SendSyntaxMessage(playerid, "/goto [entrance] [entrance ID]");

			if ((id < 0 || id >= MAX_ENTRANCES) || !EntranceData[id][entranceExists])
			    return SendErrorMessage(playerid, "You have specified an invalid entrance ID.");

		    SetPlayerPos(playerid, EntranceData[id][entrancePos][0], EntranceData[id][entrancePos][1], EntranceData[id][entrancePos][2]);
		    SetPlayerInterior(playerid, EntranceData[id][entranceExterior]);

			SetPlayerVirtualWorld(playerid, EntranceData[id][entranceExteriorVW]);
		    SendServerMessage(playerid, "You have teleported to entrance ID: %d.", id);
		    return 1;
		}
		else if (!strcmp(type, "job", true))
		{
		    if (sscanf(string, "d", id))
		        return SendSyntaxMessage(playerid, "/goto [job] [job ID]");

			if ((id < 0 || id >= MAX_DYNAMIC_JOBS) || !JobData[id][jobExists])
			    return SendErrorMessage(playerid, "You have specified an invalid job ID.");

		    SetPlayerPos(playerid, JobData[id][jobPos][0], JobData[id][jobPos][1], JobData[id][jobPos][2]);
		    SetPlayerInterior(playerid, JobData[id][jobInterior]);

			SetPlayerVirtualWorld(playerid, JobData[id][jobWorld]);
		    SendServerMessage(playerid, "You have teleported to job ID: %d.", id);
		    return 1;
		}
		else if (!strcmp(type, "gate", true))
		{
		    if (sscanf(string, "d", id))
		        return SendSyntaxMessage(playerid, "/goto [gate] [gate ID]");

			if ((id < 0 || id >= MAX_GATES) || !GateData[id][gateExists])
			    return SendErrorMessage(playerid, "You have specified an invalid gate ID.");

		    SetPlayerPos(playerid, GateData[id][gatePos][0] - (2.5 * floatsin(-GateData[id][gatePos][3], degrees)), GateData[id][gatePos][1] - (2.5 * floatcos(-GateData[id][gatePos][3], degrees)), GateData[id][gatePos][2]);
		    SetPlayerInterior(playerid, GateData[id][gateInterior]);

			SetPlayerVirtualWorld(playerid, GateData[id][gateWorld]);
		    SendServerMessage(playerid, "You have teleported to gate ID: %d.", id);
		    return 1;
		}
		else if (!strcmp(type, "interior", true))
		{
		    static
		        str[1536];

			str[0] = '\0';

			for (new i = 0; i < sizeof(g_arrInteriorData); i ++) {
			    strcat(str, g_arrInteriorData[i][e_InteriorName]);
			    strcat(str, "\n");
		    }
		    Dialog_Show(playerid, TeleportInterior, DIALOG_STYLE_LIST, "Teleport: Interior List", str, "Select", "Cancel");
		    return 1;
		}
	    else return SendErrorMessage(playerid, "You have specified an invalid player.");
	}
	if (!IsPlayerSpawned(id))
		return SendErrorMessage(playerid, "You can't teleport to a player that's not spawned.");

	SendPlayerToPlayer(playerid, id);

	format(string, sizeof(string), "You have ~y~teleported~w~ to %s.", ReturnName(id, 0));
	ShowPlayerFooter(playerid, string);

	return 1;
}
Reply
#2

pawn Код:
CMD:gotoco(playerid, params[])
{
   // check if they're admin
   new Float: x, Float: y, Float: z;
   if(sscanf(params, "fff", x, y, z)) return // send a message here or something, incorrect syntax.
   SetPlayerPos(playerid, x, y, z); // set their pos
  return 1;
}
Reply
#3

Код:
warning 217: loose indentation
I get this warning
Reply
#4

Quote:
Originally Posted by Jennifer
Посмотреть сообщение
Код:
warning 217: loose indentation
I get this warning
It should give you a line number, go there and check to make sure it isn't indented farther than it should be.
Reply
#5

The line number is one of the lines in the /gotco

more exact

Код:
  return 1;
Reply
#6

on top:
pawn Код:
#pragma tabsize 0
Reply
#7

Ok no errors/warnings

but when I write

/gotoco 647.5, -1373.59998, 17.4
or
/gotoco 647.5 -1373.59998 17.4

Instead of teleporting me to the Televison studio, it send me out to the mark in blueberry.
Reply
#8

you have to user coordinates without "," or "-"
just a space between X Y and Z.


pawn Код:
CMD:gotopos(playerid, params[])
{
        if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "you don't have permission to use this command.");
        new Float:POS[3];
        if(sscanf(params, "fff", POS[0], POS[1], POS[2])) return SendClientMessage(playerid, -1, "Usage: /gotopos X Y Z");
        SetPlayerPos(playerid, POS[0], POS[1], POS[2]);
    return 1;
}

for example i want to teleport to
X: 55.0
Y: 850.5
Z: 15.4

/gotopos 55.0 850.5 15.4
Reply
#9

Thanks works perfectly
Reply
#10

Quote:
Originally Posted by M4D
Посмотреть сообщение
on top:
pawn Код:
#pragma tabsize 0
Don't use that. Learn how to write in the correct order.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)