Lock Vehicle With Variable? - 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: Lock Vehicle With Variable? (
/showthread.php?tid=343902)
Lock Vehicle With Variable?+Rep -
Admigo - 19.05.2012
Heey all,
Is it possible to lock your vehicle with variable and not with VehicleParams so i can make when player enter vehicle he will removed from car?
Thanks Admigo
Re: Lock Vehicle With Variable? -
[HiC]TheKiller - 19.05.2012
pawn Код:
new VehicleID[MAX_PLAYERS], Locked[MAX_VEHICLES];
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER) // Player entered a vehicle as a driver
{
if(Locked[GetPlayerVehicleID(playerid)] == 1) RemovePlayerFromVehicle(playerid);
else VehicleID[playerid] = GetPlayerVehicleID(playerid);
}
return 1;
}
Just a little example. For a lock command, just put
pawn Код:
Locked[VehicleID[playerid]] = 1;
Re: Lock Vehicle With Variable?+Rep -
Admigo - 19.05.2012
Thanks dude,How can i detect the vehicle owner who locked the vehicle and how can i detect when i am the driver who locked the vehicle?
Give Rep + For it
Re: Lock Vehicle With Variable?+Rep -
Admigo - 19.05.2012
I made this:
Код:
if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER) // Player entered a vehicle as a driver
{
if(Locked[GetPlayerVehicleID(playerid)] == 1)
{
new string[256];
new pname[256];
GetPlayerName(Locked[VehicleID[playerid]], pname, sizeof(pname));
format(string,sizeof (string),"This vehicle is locked by %s[%d]!",pname,Locked[VehicleID[playerid]]);
SendClientMessage(playerid,COLOR_RED,string);
RemovePlayerFromVehicle(playerid);
}
else
{
VehicleID[playerid] = GetPlayerVehicleID(playerid);
}
}
But when i enter the vehicle it says its locked by one of my bots. How can i detect the good player who locked the vehicle?