Problem with OnPlayerEnterVehicle & lock
#1

Hey, I've got this code i put it under OnPlayerEnterVehicle Now its ment to lock the doors but for some reason it doesn't work.



Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{



  AddVehicleComponent(vehicleid, 1010); // Nitro
	SendClientMessage(playerid,0x00FFF0FF,"Nitro has been automaticly installed in your vehicle.");
	SendClientMessage(playerid,0xEBFF00FF,"The vehicle doors are now locked type /unlock to unlock them.");
	

	
	for(new i=0; i < MAX_PLAYERS; i++)
	{
			if(i == playerid) continue;
			SetVehicleParamsForPlayer(GetPlayerVehicleID(vehicleid),i,0,1);
	}
	
	PlayerPlaySound(playerid,1138, 0.0, 0.0, 0.0);
Reply
#2

If think you must use something like IsPlayerInVehicle.
Reply
#3

Quote:
Originally Posted by Flashy
If think you must use something like IsPlayerInVehicle.
Yes, But won't that just send a message and ruin the code.?


Beginner
Reply
#4

You need to lock the car doors again under OnVehicleStreamIn

https://sampwiki.blast.hk/wiki/OnVehicleStreamIn

Also, use vehicleid not GetPlayerVehicleID, because player is not inside the car yet.

pawn Код:
new gLock[MAX_VEHICLES];
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    AddVehicleComponent(vehicleid, 1010); // Nitro
    SendClientMessage(playerid,0x00FFF0FF,"Nitro has been automaticly installed in your vehicle.");
    SendClientMessage(playerid,0xEBFF00FF,"The vehicle doors are now locked type /unlock to unlock them.");
   
    gLock[vehicleid] = 1;
    for(new i=0; i < MAX_PLAYERS; i++)
    {
            if(i == playerid) continue;
            SetVehicleParamsForPlayer(vehicleid,i,0,1);
    }
   
    PlayerPlaySound(playerid,1138, 0.0, 0.0, 0.0);
pawn Код:
public OnVehicleStreamIn(vehicleid, forplayerid)
{
    if(gLock[vehicleid] == 1)
    {
        SetVehicleParamsForPlayer(vehicleid,forplayerid,0,1);
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)