Problem with locking vehicle doors
#1

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

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

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

Ah okay then,didn't know that variable is boolean.
Reply
#5

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

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

I'm not really sure,maybe try redownloading your streamer? if you're using a plugin
Reply
#8

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


Forum Jump:


Users browsing this thread: 1 Guest(s)