Teleport into vehicle - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Teleport into vehicle (
/showthread.php?tid=597655)
Teleport into vehicle -
tommzy09 - 03.01.2016
Hey guys, i've tried to make it so that when an admin teleports to a player and that player is in a vehicle, it puts the admin in the vehicle as a passenger and if that player isn't in a vehicle, the admin teleports to the players location instead.
Well, when the target player is on foot, the command works perfectly but when they're in a vehicle, it says "teleported into Players vehicle" but it doesn't put the admin in their vehicle and it doesn't even teleport them to their position.
here is my code, i can't seem to see what is wrong
Код:
CMD:goto(playerid, params[])
{
//new stringadm[64];
if(pInfo[playerid][pAdmin] <= 1) return SendClientMessage(playerid, WHITE, "SERVER: Unknown command.");
new targetid, string[128];
if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, RED, "USAGE: /goto [id/name]");
else if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, RED, "ERROR: Invalid ID/NAME!");
else if(pInfo[playerid][pLogin] == 0) return SendClientMessage(playerid, RED, "Register or Login first before using this command!");
if(pInfo[playerid][pAdmin] >= 2 || IsPlayerAdmin(playerid))
{
new pName[24];
GetPlayerName(targetid,pName,128);
new vehid;
vehid = GetPlayerVehicleID(targetid);
if (GetPlayerState(targetid) == PLAYER_STATE_DRIVER)
{
TeleportAllowed[playerid] = 1;
new iSeat = GetPlayerVehicleSeat(targetid);
PutPlayerInVehicle(playerid, vehid, iSeat);
format(string, sizeof(string), "Teleported into %s\'s Vehicle [%d].",pName, targetid);
SendClientMessage(playerid,LIME,string);
return 1;
}
format(string, sizeof(string), "Teleported to %s [%d].",pName, targetid);
SendClientMessage(playerid,LIME,string);
SetPlayerInterior(playerid,GetPlayerInterior(targetid));
SetPlayerVirtualWorld(playerid,GetPlayerVirtualWorld(targetid));
new Float:TPX, Float:TPY, Float:TPZ;
GetPlayerPos(targetid, TPX, TPY, TPZ);
TeleportAllowed[playerid] = 1;
SetPlayerPos(playerid, TPX, TPY, TPZ+1);
//format(stringadm,sizeof(stringadm),"[ADM]: %s used /goto",GetName(playerid));
//SendToAdmin(COLOR_ADM,stringadm);
}
return 1;
}
also i don't mind about checking if the seat is empty, etc.
Re: Teleport into vehicle -
tommzy09 - 03.01.2016
fixed it myself. disregard