23.02.2011, 10:57
(
Последний раз редактировалось captainjohn; 23.02.2011 в 16:58.
)
Creating teleports is easy, if you don't know I will show you.
In this tutorial I will create a teleport command to bayside.
First of all go into your filterscript/gamemode and go to.
You can press Ctrl + F to search to find this if it is easier.
Now create a new line after the { under OnPlayerCommandText.
Now we are going to add what we will type in, for it to recongnize the teleport.
So add this.
I will leave /bayside in because I am making mine teleport to Bayside, if you want to go some were else just change the /bayside
Now create a new line.
Under that your next line will be the players position, the place were the player will be teleported to.
You can get your co-ordinates for the places by going to a server or your home server or in debug mode and press /save at the place you want. To save your exact co-ordinates.
So lets get back to the tutorial.
We have this.
The next line will be this.
After the playerid, (remember to always have that space after the comma). We will add the co-ordinates.
I am doing bayside.
The co-ordinates are sperated into 3 categories.
Float X
Float Y
Float Z
My Co-ordinates are these.
Float X: -2271.0764,
Float Y: 2317.8457,
Float Z: 4.8202
Lets add them to the
So this is how it will be.
SetPlayerPos(playerid, Float, Float:y, Float:z);
Change the Float X,Y and Z to your co-ordinates.
SetPlayerPos(playerid, -2271.0764, 2317.8457, 4.8202);
So now our command looks like this.
Now we are going to add the players facing angle, the angle the player will be facing when he teleports to the location.
To do this we add a line under SetPlayerPos and put this.
Angles are from 0-360 degress. Pick your desired angle.
I will choose 180 degrees, so simply just type your angle after the playerid,
It will look like this.
Don't forget the closed bracket and semi colon after your angle
So far this is how the command should look.
Now we are going to add the client message, which will be sent to the player when he teleports there.
Once again, create a new line under the last one we did.
Now to start the client message put this under SetPlayerFacingAngle.
To put your message in, type your message in between the quotation marks.
So this is mine.
Now this is my whole command so far.
We now finish off the command by adding. Under the command.
Finally it should look like this.
//-------------------------EXTRAS-----------------------------EXTRAS-----------------------------------------
//-------------------------EXTRAS-----------------------------EXTRAS-----------------------------------------
I will show you some extras that you can do to your teleport command.
First of, give the player a weapon.
Anywere in your command, above the return 1 and below the if(strcmp("/bayside", cmdtext, true) == 0)
Add this line.
We will first get the weapon ID by going to this webpage https://sampwiki.blast.hk/wiki/Weapons
I will choose a sniper.
So my ID I need to get is ID 34.
Now back to the code, add your weapon ID after the first comma in the command (add a space aswell)
So it will look like this.
Now we want to add how much ammo the player will get once he has teleported. So after the 2nd comma and space add a number. I will add 100.
It will look like this.
Now we will add it to our command.
Now you may want to reset all the players weapons on teleport.
So just simply add this to a line in your teleport command.
Now your command will look like this.
So, so far in my commands, the player gets teleported to Bayside, his facing angle is 180 degrees, he gets a client message, his weapons get reset and he gets given a sniper with 100 ammo.
I will end this tutorial with adding the player to a virtual world.
Again, add this code into your command so far.
Now after the comma and space add a virtual world, the default for everyone is 0, so make it something other than 0.
I will use 5 for my example.
Should then look like this.
Now the whole command will look like this.
One last extra for today.
You want two commands to go to the same place like /bayside and /bs
Just do this.
This is our first line
Then we copy this next to the first line
It should look like this.
Now for the whole command should look like this.
Edit: A tutorial I made to teleport your player to a location and get a vehicle https://sampforum.blast.hk/showthread.php?tid=230467
Thank you, I hope I have helped.
I know people will say "or this is easy" but for new people, it isn't, so anyone out there who doesn't know what to do.
I hope I have helped.
In this tutorial I will create a teleport command to bayside.
First of all go into your filterscript/gamemode and go to.
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
Now create a new line after the { under OnPlayerCommandText.
Now we are going to add what we will type in, for it to recongnize the teleport.
So add this.
I will leave /bayside in because I am making mine teleport to Bayside, if you want to go some were else just change the /bayside
pawn Код:
if(strcmp("/bayside", cmdtext, true) == 0)
{
Under that your next line will be the players position, the place were the player will be teleported to.
You can get your co-ordinates for the places by going to a server or your home server or in debug mode and press /save at the place you want. To save your exact co-ordinates.
So lets get back to the tutorial.
We have this.
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if(strcmp("/bayside", cmdtext, true) == 0)
{
pawn Код:
SetPlayerPos(playerid,
I am doing bayside.
The co-ordinates are sperated into 3 categories.
Float X
Float Y
Float Z
My Co-ordinates are these.
Float X: -2271.0764,
Float Y: 2317.8457,
Float Z: 4.8202
Lets add them to the
pawn Код:
SetPlayerPos(playerid,
SetPlayerPos(playerid, Float, Float:y, Float:z);
Change the Float X,Y and Z to your co-ordinates.
SetPlayerPos(playerid, -2271.0764, 2317.8457, 4.8202);
So now our command looks like this.
pawn Код:
if(strcmp("/bayside", cmdtext, true) == 0)
{
SetPlayerPos(playerid, -2271.0764, 2317.8457, 4.8202);
To do this we add a line under SetPlayerPos and put this.
pawn Код:
SetPlayerFacingAngle(playerid,
I will choose 180 degrees, so simply just type your angle after the playerid,
It will look like this.
Don't forget the closed bracket and semi colon after your angle
pawn Код:
SetPlayerFacingAngle(playerid, 180);
pawn Код:
if(strcmp("/bayside", cmdtext, true) == 0)
{
SetPlayerPos(playerid, -2271.0764, 2317.8457, 4.8202);
SetPlayerFacingAngle(playerid, 180);
Once again, create a new line under the last one we did.
Now to start the client message put this under SetPlayerFacingAngle.
pawn Код:
SendClientMessage(playerid, 0x00FFFFAA, "");
So this is mine.
pawn Код:
SendClientMessage(playerid, 0x00FFFFAA, "Your have been teleported to Bayside.");
pawn Код:
if(strcmp("/bayside", cmdtext, true) == 0)
{
SetPlayerPos(playerid, -2271.0764, 2317.8457, 4.8202);
SetPlayerFacingAngle(playerid, 180);
SendClientMessage(playerid, 0x00FFFFAA, "Your have been teleported to Bayside.");
pawn Код:
return 1;
}
pawn Код:
if(strcmp("/bayside", cmdtext, true) == 0)
{
SetPlayerPos(playerid, -2271.0764, 2317.8457, 4.8202);
SetPlayerFacingAngle(playerid, 180);
SendClientMessage(playerid, 0x00FFFFAA, "You have been teleported to Bayside.");
return 1;
}
//-------------------------EXTRAS-----------------------------EXTRAS-----------------------------------------
//-------------------------EXTRAS-----------------------------EXTRAS-----------------------------------------
I will show you some extras that you can do to your teleport command.
First of, give the player a weapon.
Anywere in your command, above the return 1 and below the if(strcmp("/bayside", cmdtext, true) == 0)
Add this line.
pawn Код:
GivePlayerWeapon(playerid, , );
I will choose a sniper.
So my ID I need to get is ID 34.
Now back to the code, add your weapon ID after the first comma in the command (add a space aswell)
So it will look like this.
pawn Код:
GivePlayerWeapon(playerid, 34, );
It will look like this.
pawn Код:
GivePlayerWeapon(playerid, 34, 100);
pawn Код:
if(strcmp("/bayside", cmdtext, true) == 0)
{
SetPlayerPos(playerid, -2271.0764, 2317.8457, 4.8202);
SetPlayerFacingAngle(playerid, 180);
GivePlayerWeapon(playerid, 34, 100);
SendClientMessage(playerid, 0x00FFFFAA, "You have been teleported to Bayside.");
return 1;
}
So just simply add this to a line in your teleport command.
pawn Код:
ResetPlayerWeapons(playerid);
pawn Код:
if(strcmp("/bayside", cmdtext, true) == 0)
{
SetPlayerPos(playerid, -2271.0764, 2317.8457, 4.8202);
SetPlayerFacingAngle(playerid, 180);
ResetPlayerWeapons(playerid);
GivePlayerWeapon(playerid, 34, 100);
SendClientMessage(playerid, 0x00FFFFAA, "You have been teleported to Bayside.");
return 1;
}
I will end this tutorial with adding the player to a virtual world.
Again, add this code into your command so far.
pawn Код:
SetPlayerVirtualWorld(playerid, );
I will use 5 for my example.
Should then look like this.
pawn Код:
SetPlayerVirtualWorld(playerid, 5);
pawn Код:
if(strcmp("/bayside", cmdtext, true) == 0)
{
SetPlayerPos(playerid, -2271.0764, 2317.8457, 4.8202);
SetPlayerFacingAngle(playerid, 180);
ResetPlayerWeapons(playerid);
GivePlayerWeapon(playerid, 34, 100);
SetPlayerVirtualWorld(playerid, 5);
SendClientMessage(playerid, 0x00FFFFAA, "You have been teleported to Bayside.");
return 1;
}
One last extra for today.
You want two commands to go to the same place like /bayside and /bs
Just do this.
This is our first line
pawn Код:
if(strcmp("/bayside", cmdtext, true) == 0)
pawn Код:
|| (strcmp("/bs", cmdtext, true) == 0))
pawn Код:
if((strcmp("/bayside", cmdtext, true) == 0) || (strcmp("/bs", cmdtext, true) == 0))
pawn Код:
if((strcmp("/bayside", cmdtext, true) == 0) || (strcmp("/bs", cmdtext, true) == 0))
{
SetPlayerPos(playerid, -2271.0764, 2317.8457, 4.8202);
SetPlayerFacingAngle(playerid, 180);
ResetPlayerWeapons(playerid);
GivePlayerWeapon(playerid, 34, 100);
SetPlayerVirtualWorld(playerid, 5);
SendClientMessage(playerid, 0x00FFFFAA, "You have been teleported to Bayside.");
return 1;
}
Edit: A tutorial I made to teleport your player to a location and get a vehicle https://sampforum.blast.hk/showthread.php?tid=230467
Thank you, I hope I have helped.
I know people will say "or this is easy" but for new people, it isn't, so anyone out there who doesn't know what to do.
I hope I have helped.