SA-MP Forums Archive
Problem with OnPlayerEnterVehicle & lock - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Problem with OnPlayerEnterVehicle & lock (/showthread.php?tid=152657)



Problem with OnPlayerEnterVehicle & lock - Jay. - 05.06.2010

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);



Re: Problem with OnPlayerEnterVehicle & lock - Flashy - 05.06.2010

If think you must use something like IsPlayerInVehicle.


Re: Problem with OnPlayerEnterVehicle & lock - Jay. - 05.06.2010

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


Re: Problem with OnPlayerEnterVehicle & lock - MadeMan - 05.06.2010

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;
}