PDA

View Full Version : need help with teleport command


Tommeh
11/08/2014, 05:10 AM
Ok so i have this command /fly which teleports the player to another player
COMMAND:fly(playerid, params[])
{
new pname[MAX_PLAYER_NAME];
new id; /*Creates the player's name to teleport to, and the admin that initiated the command, and the target ID to teleport to.*/
if(sscanf(params,"u",id)) SendClientMessage(playerid, COLOR_ORANGE, "/fly <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, COLOR_RED, "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, COLOR_WHITE, "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;
SetPlayerPos(playerid,x,y,z+100);
//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+425);//Teleports the admin to the player's x,y, and z co-ordinates we set earlier
GivePlayerWeapon(playerid, 46, 1);

}
}
}

return 1;
}

However, I want this exact same code to teleport a player to an ACTUAL teleport spot
So as a result, I want something like this
/fly playground

Here's the actual playground coordinates
SetPlayerPos(playerid,1915.9410,-1400.3301,13.5703)

Can someone help with this?

rockhopper
11/08/2014, 05:26 AM
You can use This try it
CMD:flyplayground(playerid,params[])
{
SetPlayerPos(playerid,1915.9410,-1400.3301,13.5703)
return 1;
}
This is just basic add stuff like is player connected etc to it

Tommeh
11/08/2014, 05:36 AM
thanks, but i'm looking somwhere along the lines of making all teleport spots to be used by using /fly [teleportspot]
ex.) /fly playground, /fly lsair, /fly oilrig

dirigent00
11/08/2014, 05:47 AM
You can use this: http://forum.sa-mp.com/showthread.php?t=432871

Tommeh
11/08/2014, 07:06 AM
You can use this: http://forum.sa-mp.com/showthread.php?t=432871
the filterscript loads but the commands not working
when i try to type in /telehelp, i get command error
(i'm also logged into my rcon)
i have all plugins in the right folders also

GC
11/08/2014, 08:46 AM
COMMAND:fly(playerid, params[])
{
new pname[MAX_PLAYER_NAME];
new id;
if(!strcmp(params, "playground", true)) // Checking if params is playground
{
SetPlayerPos(playerid, xpos, ypos, zpos); // Change these with playground's x y z
}
else if(!strcmp(params, "ls", true))
{
SetPlayerPos(playerid, xpos, ypos, zpos); // Change these with your ls x y z
}
else if(sscanf(params,"u",id)) SendClientMessage(playerid, COLOR_ORANGE, "fly <place>"); /*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, COLOR_RED, "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, COLOR_WHITE, "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;
SetPlayerPos(playerid,x,y,z+100);
//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+425);//Teleports the admin to the player's x,y, and z co-ordinates we set earlier
GivePlayerWeapon(playerid, 46, 1);

}
}
}
return 1;
}

Stinged
11/08/2014, 08:50 AM
Why do you reply with stupid shit instead of giving the real answer?

Use strcmp to compare the parameter after your command.

COMMAND:fly(playerid, params[])
{
new pname[MAX_PLAYER_NAME];
new id;
if(!strcmp(params, "playground", true)) // Checking if params is playground
{
SetPlayerPos(playerid, xpos, ypos, zpos); // Change them with your location's x y z
}
else if(!strcmp(params, "ls", true))
{
// Same stuff, if you want to add more, do what I did.
}
else if(sscanf(params,"u",id)) SendClientMessage(playerid, COLOR_ORANGE, "/fly <id> OR /fly <place>"); /*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, COLOR_RED, "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, COLOR_WHITE, "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;
SetPlayerPos(playerid,x,y,z+100);
//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+425);//Teleports the admin to the player's x,y, and z co-ordinates we set earlier
GivePlayerWeapon(playerid, 46, 1);

}
}
}
return 1;
}


I added to your usage message "OR /fly <place>" just so the player knows he can teleport to players and places.

dirigent00
11/08/2014, 09:41 AM
Why to use your real answer and set your game to only one position instead of our great stupid shit which gives you much better a more positions?

Stinged
11/08/2014, 09:52 AM
Why to use your real answer and set your game to only one position instead of our great stupid shit which gives you much better a more positions?

He clearly asked that he wants to create a /fly [place] command.
I gave him the answer to his question, and not some filterscript.

prooftzm
11/08/2014, 10:05 AM
Best option for you ma' friend. It's a little bit changed but is very good.

CMD:goto(playerid, params[])
{
new ID;
if(ID == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "Player not connected.");
if(PlayerInfo[playerid] [pAdmin] >= 1)
{
if( isnull ( params ) )
return SendClientMessage(playerid, 0xFFFFFFFF,"Syntax: /goto [id]");
}
if(PlayerInfo[playerid] [pAdmin] < 1) return SendClientMessage(playerid, -1, "Your admin leve isn't high enough to use this command.");
else
{
new Float:x, Float:y, Float:z;
GetPlayerPos(ID, x, y, z);
SetPlayerPos(playerid, x+3, y+3, z);
}
return 1;
}

Tommeh
11/08/2014, 10:20 AM
Why do you reply with stupid shit instead of giving the real answer?

Use strcmp to compare the parameter after your command.

COMMAND:fly(playerid, params[])
{
new pname[MAX_PLAYER_NAME];
new id;
if(!strcmp(params, "playground", true)) // Checking if params is playground
{
SetPlayerPos(playerid, xpos, ypos, zpos); // Change them with your location's x y z
}
else if(!strcmp(params, "ls", true))
{
// Same stuff, if you want to add more, do what I did.
}
else if(sscanf(params,"u",id)) SendClientMessage(playerid, COLOR_ORANGE, "/fly <id> OR /fly <place>"); /*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, COLOR_RED, "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, COLOR_WHITE, "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;
SetPlayerPos(playerid,x,y,z+100);
//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+425);//Teleports the admin to the player's x,y, and z co-ordinates we set earlier
GivePlayerWeapon(playerid, 46, 1);

}
}
}
return 1;
}


I added to your usage message "OR /fly <place>" just so the player knows he can teleport to players and places.

yes! this worked! Thank you GC and Stinged! Eventually I may want to read my teleport location points through a file but this will do for now.

dirigent00, thanks for recommending that script....i couldn't get it to work somehow