Car unlocked only for 1 player
#1

Hey guys!

Currently I'm testing a bit VehicleParams... so what I'm trying to do is that, the specific vehicle unlocked for 1 player who is for example on some kind of mission. So here is example what i've made.

Код:
for(new i=0; i < MAX_PLAYERS; i++)
   		{
            if(i == playerid && on‌mission == 1) continue;
            SetVehicleParamsForPlayer(car_dealer_car[0],i,1,0);
        }
Код:
public OnVehicleStreamIn(vehicleid, forplayerid)
{
    if(vehicleid == car_dealer_car[0])
    {
        SetVehicleParamsForPlayer(car_dealer_car[0], forplayerid, 1, 0);
    }
    return 1;
}
But vehicle is locked for me, how can I make it will be only unlocked for me?
Reply
#2

That loop is unnecessary, you can simply use OnVehicleStreamIn callback to do it:
pawn Код:
public OnVehicleStreamIn(vehicleid, forplayerid) {

    if(vehicleid == car_dealer_car[0]) {

        if(onmission[forplayerid] == 1) //If player is in mission.
            SetVehicleParamsForPlayer(car_dealer_car[0], forplayerid, 1, 0); //Unlocks the vehicle.
        else //If not..
            SetVehicleParamsForPlayer(car_dealer_car[0], forplayerid, 1, 1); //Locks the vehicle.
    }
    return 1;
}
Reply
#3

Try to add variable like bool:OnMission[MAX_PLAYERS] = false; on top of your script.

Then on command change it to true.

Then it will be, if(OnMission[playerid] == true) SetVehicleParamsForPlayer(car_dealer_car[0],i,1,0);

Also what I think is, that continue; just finish "for", and not setting vehicle params.
Reply
#4

Thank you
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)