[HELP] Teleports - Read before posting
#1

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;
    }
Reply
#2

Nice! This really helped me alot
Reply
#3

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

Very usefull for beginners
Reply
#5

its good
Reply
#6

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

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 >.>
Reply
#8

Such an old thread.
on: June 25, 2008, 06:32:53 am »
Reply
#9

I will try to make a TP command. Ty for tutorial.
Reply
#10

Thanks Dude
Reply


Forum Jump:


Users browsing this thread: