03.12.2010, 18:15
(
Последний раз редактировалось SparkZ_; 04.12.2010 в 08:51.
)
Special Teleports
Hey, Well i found this really useful for my server, I thought I'd share it with you ^^
Know how annoying it is when you teleport to a location and your vehicle doesn't come with you?,
Even worse, When your passenger can teleport you.
Well, This tutorial will teach you exactly how to make a teleport, which teleports your vehicle and doesn't allow
Passengers to teleport while they're in your vehicle.
Lets begin.
First we need to create the body of the command
So under
pawn Код:
OnPlayerCommandText
pawn Код:
if (strcmp("/teleport", cmdtext, true) == 0)
{
return 1;
}
Код:
/teleport
Now lets create the command.
Right, we must now check if the player is a passenger.
Add this under your command:
pawn Код:
if(GetPlayerState(playerid) == PLAYER_STATE_PASSENGER)
Now, lets add something, if he is the passenger.
pawn Код:
if(GetPlayerState(playerid) == PLAYER_STATE_PASSENGER)[/code]
{
SendClientMessage(playerid,color,"You must be the driver!");//Make sure you've defined your chosen colour
}
Now that we've checked if the player is a passenger.
We can now check if he is the driver or on foot, will do this by using
pawn Код:
else
pawn Код:
if(GetPlayerState(playerid) == PLAYER_STATE_PASSENGER)[/code]
{
SendClientMessage(playerid,color,"You must be the driver!");//Make sure you've defined your chosen colour
}
else if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER || PLAYER_STATE_ONFOOT)
{
}
We must now create a variable, to store the players vehicle in.
Add this between the brackets:
pawn Код:
else if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER || PLAYER_STATE_ONFOOT)
{
new getv;
}
Okay, now that we have created are variable, lets get the players vehicle!
Add this under new getv;
pawn Код:
else if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER || PLAYER_STATE_ONFOOT)
{
new getv;
getv = GetPlayerVehicleID(playerid);
}
Will now move on to the actual teleport.
under
pawn Код:
getv = GetPlayerVehicleID(playerid)
pawn Код:
else if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER || PLAYER_STATE_ONFOOT)
{
new getv;
getv = GetPlayerVehicleID(playerid);
SetPlayerPos(playerid,x,y,z)//Change x,y,z to your teleport coords.
SetVehiclePos(getv,x,y,z)//Again change x,y,z to your teleport coords, must be the same as SetPlayerPos!
}
Now, to finish off, lets put the player in his vehicle, using
pawn Код:
PutPlayerInVehicle
pawn Код:
SetPlayerPos and SetVehiclePos
pawn Код:
PutPlayerInVehicle(playerid,getv,0);
Done!, If you done this correctly, your command should look similar to this:
pawn Код:
if (strcmp("/teleport", cmdtext, true) == 0)
{ if(GetPlayerState(playerid) == PLAYER_STATE_PASSENGER)
{
SendClientMessage(playerid,color,"You must be the driver");
}
else if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT || PLAYER_STATE_DRIVER)
{
new getv = GetPlayerVehicleID(playerid);
SetVehiclePos(getv,-2337.2236,-1650.2164,483.7031);
SetPlayerPos(playerid,-2337.2236,-1650.2164,483.7031);
PutPlayerInVehicle(playerid,getv,0);
}
return 1;
}
Hope this helped and if i failed, please say so |:
SparkZ_