[Tutorial] Making A Simple Teleport Command [PART 1] (For Beginners)
#1

Making A Teleport Tutorial
Hi,in this tutorial ill be showing how to make a simple teleport,this tutorial is for beginners.

The things we need for this tutorial are listed below

Includes:
ZCMD - I recommend this include for making commands,its fast and easier.

Using ZCMD
This is the easiest way of using zcmd
Код:
CMD:yourcommand(playerid, params[])
{
    return 1;
}
Getting The Coordinates

For making a teleport you will need the coordinates of a place where you want the player to teleport.For this you can use /rs command which is a SA-MP Client command,you can use this command in any server anywhere.Actually the function of the command is to save the coordinates of the place where you are standing into a file,you can get these coordinates from (%systemdrive%\Users\%username%\Documents\GTA San Andreas User Files\SAMP\rawpositions.txt)


Making The Basic Command

So now forexample i want to make a teleport for Area 51 Base,and i got my coordinates in the file like this (135.20, 1948.51, 19.74, 180.0)
Here is how the coordinates are saved using (/rs) command:
Код:
X Position, Y Position, Z Position [Height], Angle
So now we will be using this in a function "SetPlayerPos" which is used to set the player's position to a custom position.

Here is our command
Код:
CMD:teleport(playerid, params[])
{
    return 1;
}
And now we will use the "SetPlayerPos" function
Код:
CMD:teleport(playerid, params[])
{
    //Usage: SetPlayerPos(playerid, x, y, z);
    //Ive already explained how the coordinates are saved,according to that,get the x,y,z coordinates and paste them like the way i did.
    SetPlayerPos(playerid, 135.20, 1948.51, 19.74);
    return 1;
}
Now you've made you teleport command,but it needs some more lines of code to make it free of bug,as if you use the command,it will not set your facing angle to the angle you saved.

So here we will use "SetPlayerFacingAngle" function to do this job.

Код:
CMD:teleport(playerid, params[])
{
    //Usage: SetPlayerPos(playerid, x, y, z);
    //Ive already explained how the coordinates are saved,according to that,get the x,y,z coordinates and paste them like the way i did.
    SetPlayerPos(playerid, 135.20, 1948.51, 19.74);

    //Usage: SetPlayerFacingAngle(playerid, angle);
    //Now you will have to paste the facing angle coordinates in the function as i did below.
    SetPlayerFacingAngle(playerid, 180.0);
    return 1;
}
Now,you will need to set the player's interior id to the teleport's interior id,so the player will not be bugged,to get the interior id you can use /interior command in-game and it will show you interior id in the chat,As area51 interior is 0,ill be setting the player's interior to 0 using the "SetPlayerInterior" function.

Код:
CMD:teleport(playerid, params[])
{
    //Usage: SetPlayerInterior(playerid, interior id);
    SetPlayerInterior(playerid, 0);

    //Usage: SetPlayerPos(playerid, x, y, z);
    //Ive already explained how the coordinates are saved,according to that,get the x,y,z coordinates and paste them like the way i did.
    SetPlayerPos(playerid, 135.20, 1948.51, 19.74);

    //Usage: SetPlayerFacingAngle(playerid, angle);
    //Now you will have to paste the facing angle coordinates in the function as i did below.
    SetPlayerFacingAngle(playerid, 180.0);
    return 1;
}
More On Part 2..
Reply
#2

Looks nice and neat, decent one !
Reply
#3

Thanks
Reply
#4

Lots of tutorials, regarding making a teleport commands :/
Reply
#5

Freezing the player after the teleport will slightly improved it making it look proper
Reply
#6

Quote:
Originally Posted by Arastair
Посмотреть сообщение
Freezing the player after the teleport will slightly improved it making it look proper
There are no objects that are mapped in the teleport,gta sa objects are loaded automatically when we connect to the server so freezing the player will be useless,well if you want it,i can add it in the part 2
Reply
#7

Quote:
Originally Posted by K0P
Посмотреть сообщение
There are no objects that are mapped in the teleport,gta sa objects are loaded automatically when we connect to the server so freezing the player will be useless,well if you want it,i can add it in the part 2
When a player gets teleported, the player will fall and then the objects will load, for beginners it's not necessary to know or do this, just saying it'll improve it
Reply
#8

Quote:
Originally Posted by Arastair
Посмотреть сообщение
When a player gets teleported, the player will fall and then the objects will load, for beginners it's not necessary to know or do this, just saying it'll improve it
i made a tutorial for that yesterday
Reply
#9

Quote:
Originally Posted by Arastair
Посмотреть сообщение
When a player gets teleported, the player will fall and then the objects will load, for beginners it's not necessary to know or do this, just saying it'll improve it
Player will not fall from the default map of gta sa,you can test it by yourself too.
Reply
#10

Quote:
Originally Posted by K0P
Посмотреть сообщение
Player will not fall from the default map of gta sa,you can test it by yourself too.
It seems like you can't understand what I'm saying
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)