[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


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)