Car unlocked only for 1 player - 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)
+--- Thread: Car unlocked only for 1 player (
/showthread.php?tid=606101)
Car unlocked only for 1 player -
Lajko1 - 29.04.2016
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 && onmission == 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?
Re: Car unlocked only for 1 player -
Lordzy - 29.04.2016
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;
}
Re: Car unlocked only for 1 player -
slipnkit - 29.04.2016
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.
Re: Car unlocked only for 1 player -
Lajko1 - 29.04.2016
Thank you