SetVehicleParamsForPlayer maybe little bugs, big thanks for your replies!
#1

Hello guys, please can someone tell me what is causing this bug? I will explain the situation. I am using command SetVehicleParamsForPlayer to lock vehicles for players, what aren't working in Police faction. And for example when normal player comes near to this police car, and he press F/ENTER to enter vehicle, he will run to enter vehicle and it will do following: (When is player entering the doors, it will show so it is locked)



But, when player leaves the vehicle and when he tries to enter it again, it won't do it again, player just keep stand on same position and he won't run to enter car.

Second thing is, when player got set his job to 1 (1 means so he is able to ride, and he can enter the police cruiser), then problem arrives. When player press F/ENTER to enter vehicle it won't do something, he is still standing on same position, but when players press G to car and he enters it and then he leave car, then it'll work correctly. When player again press F/ENTER to enter vehicle, he'll just normally get in.

Posting my codes, what are doing this:

pawn Код:
new PoliceCruiser[MAX_VEHICLES];

public OnGameModeInit ()
{
    SetGameModeText ("Las Venturas Roleplay");
    PoliceCruiser [1] =  AddStaticVehicle (598, 2251.6812, 2443.6890, 10.5676, 0, 0, 1);
    PoliceCruiser [2] =  AddStaticVehicle (598, 2256.0208, 2443.6890, 10.5676, 0, 0, 1);
    PoliceCruiser [3] =  AddStaticVehicle (598, 2260.3676, 2443.6890, 10.5676, 0, 0, 1);
    return true;
}

public OnPlayerEnterVehicle (playerid, vehicleid, ispassenger)
{
    for (new i = 0; i < 12; i++)
    {
        if (vehicleid == PoliceCruiser [i])
        {
            if (PlayerInfo [playerid] [pFaction] == 1)
            {
                SetVehicleParamsForPlayer (PoliceCruiser [i], playerid, 0, 0);
            }
            else
            if (PlayerInfo [playerid] [pFaction] != 1)
             {
                SetVehicleParamsForPlayer (PoliceCruiser [i], playerid, 0, 1);
               
            }
        }
    }
    return true;
}
Really big thanks for responsing to me!
Reply
#2

Try:

pawn Код:
public OnPlayerEnterVehicle (playerid, vehicleid, ispassenger)
{
    new id = GetVehicleModel(vehicleid);
    if(id == 598)//police cruiser model id.
    {
        if(!ispassenger)
        {
            ClearAnimations(playerid,1);
        }
    }
    return true;
}
I do it that way since i stop players from entering PD cars in none cop class.

Edit; dont forget to add the check to see if they're cop.
Reply
#3

Yeah mate, I was trying these "ClearAnimations" but I don't like how its "bugging" player head, when player spams it for example.
Reply
#4

Well, I'm not actually very interested in that locked car system, when you have some ideas how I can keep car locked for player, who isn't working in police faction, and policeman without any problems enter this vehicle, type here. Thanks.
Reply
#5

Try this:

Under the SetVehicleParamsForPlayer add this:
Код:
SetTimerEx("CarLocked", 500, false, "ii", playerid, vehicleid);
It'll looks:
Код:
public OnPlayerEnterVehicle (playerid, vehicleid, ispassenger)
{
    for (new i = 0; i < 12; i++)
    {
        if (vehicleid == PoliceCruiser [i])
        {
            if (PlayerInfo [playerid] [pFaction] != 1)
            {
                SetVehicleParamsForPlayer (PoliceCruiser [i], playerid, 0, 1);
		SetTimerEx("CarLocked", 3000, false, "ii", playerid, vehicleid);
            }
        }
    }
    return true;
}
And on the end of code add:
This makes that the car will be unlocked - the animation starts again if a player presses F
Код:
forward CarLocked(playerid, vehicleid);
public CarLocked(playerid, vehicleid)
{
	SetVehicleParamsForPlayer(vehicleid, playerid, false, false);
	return 1;
}
Sorry, for my bad English. I'm Czech.

//EDIT: A little mistake - the timer for 500 is small. When you are farther you can enter the car. So change 500 to 3000 - it should be ok
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)