need help with teleport command
#1

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?
Reply
#2

You can use This try it
pawn Код:
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
Reply
#3

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
Reply
#4

You can use this: https://sampforum.blast.hk/showthread.php?tid=432871
Reply
#5

Quote:
Originally Posted by dirigent00
Посмотреть сообщение
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
Reply
#6

PHP код:
COMMAND:fly(playeridparams[])
{
        new 
pname[MAX_PLAYER_NAME];
        new 
id;
        if(!
strcmp(params"playground"true)) // Checking if params is playground
        
{
            
SetPlayerPos(playeridxposyposzpos); // Change these with playground's x y z 
        
}
        else if(!
strcmp(params"ls"true))
        {
           
SetPlayerPos(playeridxposyposzpos); // Change these with your ls x y z 
        
}
        else if(
sscanf(params,"u",id)) SendClientMessage(playeridCOLOR_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(playeridCOLOR_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(playeridCOLOR_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(playerid461);
            }
        }
    }
    return 
1;

Reply
#7

Why do you reply with stupid shit instead of giving the real answer?

Use strcmp to compare the parameter after your command.
pawn Код:
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.
Reply
#8

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?
Reply
#9

Quote:
Originally Posted by dirigent00
Посмотреть сообщение
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.
Reply
#10

Quote:
Originally Posted by Stinged
Посмотреть сообщение
Why do you reply with stupid shit instead of giving the real answer?

Use strcmp to compare the parameter after your command.
pawn Код:
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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)