Lock Vehicle With Variable?
#1

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
Reply
#2

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;
Reply
#3

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
Reply
#4

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?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)