SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 11/08/2014, 05:10 AM   #1
Tommeh
Little Clucker
 
Join Date: May 2012
Posts: 21
Reputation: 0
Default need help with teleport command

Ok so i have this command /fly which teleports the player to another player
Code:
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
Code:
SetPlayerPos(playerid,1915.9410,-1400.3301,13.5703)
Can someone help with this?
Tommeh is offline   Reply With Quote
Old 11/08/2014, 05:26 AM   #2
rockhopper
Gangsta
 
rockhopper's Avatar
 
Join Date: Apr 2014
Location: In A Black Hole Under You !
Posts: 603
Reputation: 33
Default Re: need help with teleport command

You can use This try it
pawn Code:
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
__________________
I love it <3 <3 <3
rockhopper is offline   Reply With Quote
Old 11/08/2014, 05:36 AM   #3
Tommeh
Little Clucker
 
Join Date: May 2012
Posts: 21
Reputation: 0
Default Re: need help with teleport command

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
Tommeh is offline   Reply With Quote
Old 11/08/2014, 05:47 AM   #4
dirigent00
Big Clucker
 
Join Date: Jul 2014
Posts: 72
Reputation: 1
Default Re: need help with teleport command

You can use this: http://forum.sa-mp.com/showthread.php?t=432871
dirigent00 is offline   Reply With Quote
Old 11/08/2014, 07:06 AM   #5
Tommeh
Little Clucker
 
Join Date: May 2012
Posts: 21
Reputation: 0
Default Re: need help with teleport command

Quote:
Originally Posted by dirigent00 View Post
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
Tommeh is offline   Reply With Quote
Old 11/08/2014, 08:46 AM   #6
GC
Little Clucker
 
Join Date: Aug 2014
Posts: 3
Reputation: 1
Default Re: need help with teleport command

PHP Code:
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;


Last edited by GC; 11/08/2014 at 09:42 AM.
GC is offline   Reply With Quote
Old 11/08/2014, 08:50 AM   #7
Stinged
High-roller
 
Join Date: Feb 2013
Posts: 1,571
Reputation: 187
Default Re: need help with teleport command

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

Use strcmp to compare the parameter after your command.
pawn Code:
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.
Stinged is offline   Reply With Quote
Old 11/08/2014, 09:41 AM   #8
dirigent00
Big Clucker
 
Join Date: Jul 2014
Posts: 72
Reputation: 1
Default Re: need help with teleport command

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?
dirigent00 is offline   Reply With Quote
Old 11/08/2014, 09:52 AM   #9
Stinged
High-roller
 
Join Date: Feb 2013
Posts: 1,571
Reputation: 187
Default Re: need help with teleport command

Quote:
Originally Posted by dirigent00 View Post
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.
Stinged is offline   Reply With Quote
Old 11/08/2014, 10:05 AM   #10
prooftzm
Big Clucker
 
Join Date: Jun 2014
Posts: 107
Reputation: 0
Default Re: need help with teleport command

Best option for you ma' friend. It's a little bit changed but is very good.
pawn Code:
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;
}
prooftzm is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Teleport Command Luke_James Scripting Help 2 25/08/2012 07:20 PM
Help with Teleport Command crazzyt9 Help Archive 3 04/04/2011 08:23 AM
Need Help With This Teleport Command! Elmerz_com Help Archive 14 18/01/2011 07:24 PM
Help with a teleport command BurnOutt Help Archive 4 08/05/2010 02:39 PM
need help with teleport! command unique1801 Help Archive 10 22/10/2009 07:22 PM


All times are GMT. The time now is 06:52 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.