Teleport vehicle with play help -
SeifGeny - 09.07.2017
I want to teleport a vehicle with a player
so if he in any vehicle it teleport with him
if not just he teleport only
here my code
Код:
CMD:sfa(playerid, params[])
{
new string[256];
new tele[MAX_PLAYERS];
SetPlayerPos(playerid,-1657.6793, -165.2959, 14.1484);
GameTextForPlayer(playerid, "~w~San Fierro Airport", 1500, 4);
GetPlayerName(playerid, tele, sizeof(tele));
format(string, sizeof(string), "%s Has Just Teleported To San Fierro Airport", tele, playerid);
return SendClientMessageToAll(COLOR_GREEN, string);
}
Re: Teleport vehicle with play help - Astralis - 09.07.2017
pawn Код:
CMD:sfa(playerid, params[])
{
new string[256];
new tele[MAX_PLAYERS];
if(IsPlayerInAnyVehicle(playerid))
{
new vehicleid = GetPlayerVehicleID(playerid);
SetPlayerPos(playerid,-1657.6793, -165.2959, 14.1484);
SetVehiclePos(vehicleid,-1657.6793, -165.2959, 14.1484);
PutPlayerInVehicle(playerid,vehicleid,0);
GameTextForPlayer(playerid, "~w~San Fierro Airport", 1500, 4);
GetPlayerName(playerid, tele, sizeof(tele));
format(string, sizeof(string), "%s Has Just Teleported To San Fierro Airport", tele, playerid);
SendClientMessageToAll(COLOR_GREEN, string);
}
else
{
SetPlayerPos(playerid,-1657.6793, -165.2959, 14.1484);
GameTextForPlayer(playerid, "~w~San Fierro Airport", 1500, 4);
GetPlayerName(playerid, tele, sizeof(tele));
format(string, sizeof(string), "%s Has Just Teleported To San Fierro Airport", tele, playerid);
SendClientMessageToAll(COLOR_GREEN, string);
}
return 1;
}
Re: Teleport vehicle with play help -
Meller - 09.07.2017
PHP код:
CMD:sfa(playerid, params[]) {
new string[256], tele[MAX_PLAYERS], seat = GetPlayerVehicleSeat(playerid);
if(seat != -1) {
if(seat == 0) {
SetVehiclePos(GetPlayerVehicleID(playerid),-1657.6793, -165.2959, 14.1484);
}
else
SendClientMessage(playerid, -1, "You must be the driver to teleport you and the vehicle.");
}
else
SetPlayerPos(playerid,-1657.6793, -165.2959, 14.1484);
GameTextForPlayer(playerid, "~w~San Fierro Airport", 1500, 4);
GetPlayerName(playerid, tele, sizeof(tele));
format(string, sizeof(string), "%s Has Just Teleported To San Fierro Airport", tele, playerid);
return SendClientMessageToAll(COLOR_GREEN, string);
}
What I did is optimize the code by gathering the players vehicle seat, this allows me to check if the player is in a car overall, and if his seat is drivers. And if he's the driver, then I actually gather the vehicle id.
Small things like this speeds up the proccess by a few milliseconds which everyone seems to care about in the SAMP community.
Re: Teleport vehicle with play help -
SeifGeny - 09.07.2017
both worked +rep