Police lights turn off all the time -
Gerira Gaijin - 19.02.2012
When I type /lock, police lights and sirens turn off. This is my code, I don't see what's wrong with it:
pawn Код:
CMD:lock(playerid)
{
if(GetPlayerColor(playerid) == COLOR_POLICE)
{
for(new v = 0; v < MAX_VEHICLES; v ++)
{
for(new i=0;i<MAX_CUSTOM_VEHICLES;i++){
if(v == car[i])
{
new Float: vpos[3];
GetVehiclePos(v,vpos[0],vpos[1],vpos[2]);
if(IsPlayerInRangeOfPoint(playerid,3.0,vpos[0],vpos[1],vpos[2]))
{
new engine,lights,alarm,doors,bonnet,boot,objective, string[80];
GetVehicleParamsEx(v,engine,lights,alarm,doors,bonnet,boot,objective);
if (doors != VEHICLE_PARAMS_ON)
{
//SetVehicleParamsEx(v,engine,lights,alarm,VEHICLE_PARAMS_ON,bonnet,boot,objective);
SetVehicleParamsForAll(v, 0, 1);
format(string, sizeof(string), "~w~%s ~r~Locked",GetVehicleName(v));
GameTextForPlayer(playerid, string, 1000, 4);
return 1;
}
else
{
//SetVehicleParamsEx(v,engine,lights,alarm,VEHICLE_PARAMS_OFF,bonnet,boot,objective);
SetVehicleParamsForAll(v, 0, 0);
format(string, sizeof(string), "~w~%s ~g~UnLocked",GetVehicleName(v));
GameTextForPlayer(playerid, string, 1000, 4);
return 1;
}
}
}
}
}
}
return 0;
}
Re: Police lights turn off all the time -
Madd Kat - 19.02.2012
need to see the function SetVehicleParamsForAll
or go back to using the SetVehicleParamsEx you have commented out in your code
Re: Police lights turn off all the time -
Gerira Gaijin - 19.02.2012
Here it is
pawn Код:
public SetVehicleParamsForAll(carid,objective,doorslocked)
{
for(new i=0; i<MAX_PLAYERS; i++)
{
SetVehicleParamsForPlayer(carid,i,objective,doorslocked);
}
return 1;
}
Re: Police lights turn off all the time -
milanosie - 19.02.2012
also, the weather could be the problem
some weather ID's don't support lights
Re: Police lights turn off all the time -
Madd Kat - 19.02.2012
here is what I use..
can be set for any veh param but here it is
pawn Код:
enum eVehicleParams: {
engine = 0,
lights = 1,
alarm = 2,
doors = 3,
bonnet = 4,
boot = 5,
objective = 6
}
stock ToggleVehicleParamsEx(vehicleid,eVehicleParams:type,bool:enable)
{
new iengine, ilights, ialarm, idoors, ibonnet, iboot, iobjective;
GetVehicleParamsEx(vehicleid, iengine, ilights, ialarm, idoors, ibonnet, iboot, iobjective);
switch(type)
{
case 0:{SetVehicleParamsEx(vehicleid, enable, ilights, ialarm, idoors, ibonnet, iboot, iobjective);}
case 1:{SetVehicleParamsEx(vehicleid, iengine, enable, ialarm, idoors, ibonnet, iboot, iobjective);}
case 2:{SetVehicleParamsEx(vehicleid, iengine, ilights, enable, idoors, ibonnet, iboot, iobjective);}
case 3:{SetVehicleParamsEx(vehicleid, iengine, ilights, ialarm, enable, ibonnet, iboot, iobjective);}
case 4:{SetVehicleParamsEx(vehicleid, iengine, ilights, ialarm, idoors, enable, iboot, iobjective);}
case 5:{SetVehicleParamsEx(vehicleid, iengine, ilights, ialarm, idoors, ibonnet, enable, iobjective);}
case 6:{SetVehicleParamsEx(vehicleid, iengine, ilights, ialarm, idoors, ibonnet, iboot, enable);}
}
return 1;
}
usage: for the doors,
pawn Код:
ToggleVehicleParamsEx(vehicleid,3,0); // unlocks doors
ToggleVehicleParamsEx(vehicleid,3,1); //locks doors