Problem with locking vehicle doors -
Cypress - 13.12.2013
Hello.
I want a vehicle to have all of it's doors closed for all players except one. However there is a problem. Only the drivers door is getting locked and the passenger's doors stay open so if I press g, I will get into passenger seat.
Another problem is that when the drivers door is locked and you sit in the car as passenger, when you exit, the drivers door unlocks.
pawn Код:
public OnVehicleStreamIn(vehicleid, forplayerid)
{
if (vehicleid == gData[G_PACKAGE_VEHICLE])
{
if (GetPlayerTeam(forplayerid) <= 4)
{
if (gData[G_PACKAGE_STARTED])
{
if (forplayerid != gData[G_PACKAGE_DRIVER])
{
SetVehicleParamsForPlayer(vehicleid, forplayerid, 0, 1);
}
}
else SetVehicleParamsForPlayer(gData[G_PACKAGE_VEHICLE], forplayerid, 0, 0);
}
}
return 1;
}
Any solution?
Re: Problem with locking vehicle doors -
Tagathron - 13.12.2013
You're not checking anything at this line:
pawn Код:
if (gData[G_PACKAGE_STARTED])
gData[G_PACKAGE_STARTED] is just an array but you're not doing something like:
pawn Код:
f (gData[G_PACKAGE_STARTED]==1)
or similar,that would check something,this way it doesn't.
If the driver's door unlocks after leaving the vehicle try adding code to OnPlayerExitVehicle() which will set the door paramater to locked.
Re: Problem with locking vehicle doors -
Cypress - 13.12.2013
Quote:
Originally Posted by Tagathron
You're not checking anything at this line:
pawn Код:
if (gData[G_PACKAGE_STARTED])
gData[G_PACKAGE_STARTED] is just an array but you're not doing something like:
pawn Код:
f (gData[G_PACKAGE_STARTED]==1)
or similar,that would check something,this way it doesn't.
If the driver's door unlocks after leaving the vehicle try adding code to OnPlayerExitVehicle() which will set the door paramater to locked.
|
You are wrong. You don't have to add the check for == 1. I'm using Boolean which is true/false. The way I check means it is true and if adding ! means false!
pawn Код:
if ( gData[G_PACKAGE_STARTED] ) // true
if ( !gData[G_PACKAGE_STARTED] ) // false
Waiting for any other idea or solution.
Re: Problem with locking vehicle doors -
Tagathron - 13.12.2013
Ah okay then,didn't know that variable is boolean.
Re: Problem with locking vehicle doors -
Cypress - 14.12.2013
Quote:
Originally Posted by Tagathron
Ah okay then,didn't know that variable is boolean.
|
Well even if it wouldn't be boolean variable it still would work that way, I just mentioned it.
Anyone got any idea so far?
Re: Problem with locking vehicle doors -
RajatPawar - 14.12.2013
How about you lock the doors under a different call back and then reapply this in the vehicle stream callback?
https://sampwiki.blast.hk/wiki/Function:...aramsForPlayer
It says you gotta reapply the function under streaming callback.
Re: Problem with locking vehicle doors -
Tagathron - 14.12.2013
I'm not really sure,maybe try redownloading your streamer? if you're using a plugin
Re: Problem with locking vehicle doors -
Cypress - 14.12.2013
Quote:
Originally Posted by Tagathron
I'm not really sure,maybe try redownloading your streamer? if you're using a plugin
|
What does streamer have to do with the above?
I'll try what Rajat said.
EDIT:
I found solved the problem. I just realized that passenger's door was being unlocked for all vehicles under OnPlayerEnterVehicle, sorry for the inconvenience.