SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 25/06/2008, 01:32 PM   #1
Zezombia
Huge Clucker
 
Join Date: Apr 2008
Posts: 415
Reputation: 33
Default [HELP] Teleports - Read before posting

To get the location...

1) First you have to go in-game, then you have to travel to the place you want. Once there, you have to /save. With save you can just do it like that, or you can do /save [comment].

2) Now you can go to your "Rockstar Games" directory, go in to "GTA San Andreas" then find a text document called savedpositions.txt. Within it you will have the coordinates to the place you were in.

_________________________________________________

To extract the coordinates...

If you were in a car, you now have something that looks like this:
AddStaticVehicle(496,-1972.4789,256.7105,34.8884,91.4832,53,56);

In that case, you have:
AddStaticVehicle(modelid,x,y,z,angle,color1,color2);

If you were on foot, you have something that looks like this:
AddPlayerClass(0,-1972.6334,277.9128,35.1719,89.8026,0,0,0,0,0,0);

In that case, you have:
AddPlayerClass(skinid, x, y, z, angle, weapon, ammo, weapon, ammo, weapon, ammo);

What we need of course is the x, y and z.

_________________________________________________

To make the teleport...

First lets make on that only teleports people on-foot. The function you have to use is SetPlayerPos.

pawn Code:
SetPlayerPos(playerid, x, y, z);

Easy. Now if we were going to make one that teleports you in a car as well...

pawn Code:
if(IsPlayerInAnyVehicle(playerid) == 1)
    {
        SetVehiclePos(GetPlayerVehicleID(playerid), x, y, z);
    }
    else
    {
        SetPlayerPos(playerid, x, y, z);
    }

_________________________________________________

Getting more advanced...

Say you would want the teleporter to be facing a certain way when he teleports? For that we would need the angle. To back to the "extract the coordinates" thing and find the purple numbers.

If you want a vehicle to face that way, use:
pawn Code:
SetVehicleZAngle(GetPlayerVehicleID(playerid), angle)

If you want the player to face that way, do:
pawn Code:
SetPlayerFacingAngle(playerid, angle)

Now if you want to set an interior, in which all teleports should have, then you have to add the interior ID. You can get the ID by going into the place in-game and doing /interior, or you can look here.

This is typically:
pawn Code:
SetPlayerInterior(playerid, interior);

If you don't want you vehicle to be invisible, do:
pawn Code:
LinkVehicleToInterior(GetPlayerVehicleID(playerid), interior);

In the very end you would have something looking like this:
pawn Code:
if(strcmp("/teleport", cmdtext, true) == 0)
    {
        if(IsPlayerInAnyVehicle(playerid) == 1)
        {
            SetVehiclePos(GetPlayerVehicleID(playerid), x, y, z);
            SetVehicleZAngle(GetPlayerVehicleID(playerid), angle)
            SetPlayerInterior(playerid, interior);
            LinkVehicleToInterior(GetPlayerVehicleID(playerid), interior);
        }
        else
        {
            SetPlayerPos(playerid, x, y, z);
            SetPlayerFacingAngle(playerid, angle);
            SetPlayerInterior(playerid, interior);
        }
        return 1;
    }
Zezombia is offline   Reply With Quote
Old 27/07/2008, 12:09 PM   #2
bFe
Little Clucker
 
Join Date: Feb 2008
Location: Norway
Posts: 27
Reputation: 0
Default Re: [HELP] Teleports - Read before posting

Nice! This really helped me alot
bFe is offline   Reply With Quote
Old 27/07/2008, 12:43 PM   #3
Donny_k
Gangsta
 
Donny_k's Avatar
 
Join Date: May 2006
Posts: 786
Reputation: 4
Default Re: [HELP] Teleports - Read before posting

You are best checking the players state first and then dealing with what you are going to teleport (vehicle, player), this can also be used to stop passengers being able to teleport your vehicle when you don't want to be teleported. It is best to load the interior before setting the position also so you don't fall through the floor in certain interiors.

pawn Code:
if ( !strcmp( "/teleport", cmdtext, true ) )
{
  switch ( GetPlayerState( playerid ) )
  {
    case 2 :
    {
      SetPlayerInterior( playerid, interior );
      LinkVehicleToInterior( GetPlayerVehicleID( playerid ), interior );
      SetVehiclePos( GetPlayerVehicleID( playerid ), x, y, z );
      SetVehicleZAngle( GetPlayerVehicleID( playerid ), angle )
    }
    case 1,3 :
    {
      SetPlayerInterior( playerid, interior );
      SetPlayerPos( playerid, x, y, z );
      SetPlayerFacingAngle( playerid, angle );
    }
    default : return SendClientMessage( playerid, 0xafafafff, "Invalid action" ); //grey
  }
  SendClientMessage( playerid, 0xffffffff, "Welcome to the BLAH teleport" ); //white
  return 1;
}
__________________
We don't stop playing because we grow old, we grow old because we stop playing.
Donny_k is offline   Reply With Quote
Old 27/11/2008, 04:30 PM   #4
AiVAMAN
Gangsta
 
AiVAMAN's Avatar
 
Join Date: Sep 2008
Location: Lietuva
Posts: 540
Reputation: 0
Default Re: [HELP] Teleports - Read before posting

Very usefull for beginners
AiVAMAN is offline   Reply With Quote
Old 27/03/2009, 08:38 PM   #5
fff
Big Clucker
 
Join Date: Sep 2007
Posts: 74
Reputation: 0
Default Re: [HELP] Teleports - Read before posting

its good
fff is offline   Reply With Quote
Old 30/04/2009, 05:51 PM   #6
kevin13
Little Clucker
 
Join Date: Sep 2007
Posts: 23
Reputation: 0
Default Re: [HELP] Teleports - Read before posting

How do i make this, I took the coordinates for the place where i want to enter the house, then i searched for the interior ID for the house int, But how can i do this, where i have do put the coordinates and what i have do write there..? Please help

I have looked wiki,****** and searched on sa-mp
kevin13 is offline   Reply With Quote
Old 30/04/2009, 05:55 PM   #7
Weirdosport
High-roller
 
Join Date: Jul 2008
Posts: 1,293
Reputation: 0
Default Re: [HELP] Teleports - Read before posting

Quote:
Originally Posted by Donny
You are best checking the players state...
+ 1

Also, it'd be better off marked [Tutorial] Otherwise it looks like a desperate plea for help >.>
Weirdosport is offline   Reply With Quote
Old 30/04/2009, 05:56 PM   #8
MenaceX^
High-roller
 
Join Date: Aug 2008
Posts: 3,262
Reputation: 13
Default Re: [HELP] Teleports - Read before posting

Such an old thread.
on: June 25, 2008, 06:32:53 am
MenaceX^ is offline   Reply With Quote
Old 29/08/2010, 11:52 AM   #9
(LifeStealeR)
Big Clucker
 
(LifeStealeR)'s Avatar
 
Join Date: Jul 2010
Location: Romania
Posts: 128
Reputation: 0
Default Re: [HELP] Teleports - Read before posting

I will try to make a TP command. Ty for tutorial.
(LifeStealeR) is offline   Reply With Quote
Old 10/04/2012, 02:48 PM   #10
megamind2067
Huge Clucker
 
megamind2067's Avatar
 
Join Date: Mar 2012
Location: I don't know :'(
Posts: 211
Reputation: 12
Default Re: [HELP] Teleports - Read before posting

Thanks Dude
megamind2067 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
Frequently Asked Questions [READ THIS BEFORE POSTING] Woet Server Support 87 21/06/2018 01:56 PM
Common compiling errors - READ BEFORE POSTING ERRORS Streetplaya Help Archive 0 23/01/2010 11:20 AM
Please Read >>>> How To Add Play Class Selection Music? <<<< Please Read DeltaAirlines12 Help Archive 8 15/08/2009 10:41 PM


All times are GMT. The time now is 11:17 AM.


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