GetVehicleParamsSirenState(vehicleid) : 2 possible bugs -
zeax - 18.04.2015
I've been fiddling around with the new functions for siren state; and I may have came across 2 bugs, or my script is wrong.
First bug:
On and off ids are different to stated ids on the wiki.
Код:
new siren = GetVehicleParamsSirenState(vehicleid);
if(siren) TextDrawSetString(vELSTD[vehicleid][4], "~y~ON");
else TextDrawSetString(vELSTD[vehicleid][4], "OFF");
With that code, it shows OFF when the lights are actually ON. Same for the other way round.
When changed to
Код:
new siren = GetVehicleParamsSirenState(vehicleid);
if(siren == 0) TextDrawSetString(vELSTD[vehicleid][4], "~y~ON");
else if(siren == 1) TextDrawSetString(vELSTD[vehicleid][4], "OFF");
it works. But on the wiki it states:
Return Values:
0: Vehicle siren is off
1: Vehicle siren is on
Код:
if(siren)
{
// Siren is on, do something
}
else
{
// Siren is off, do something
}
Second bug:
I have to press the sirens twice before it actually detects the sirens as ON. when having :
Код:
stock ToggleELSPanelItem(vehicleid, itemid)
{
switch(itemid)
{
case ELS_PANEL_SIREN:
{
new siren = GetVehicleParamsSirenState(vehicleid);
if(siren == 0) TextDrawSetString(vELSTD[vehicleid][4], "~y~ON");
else if(siren == 1) TextDrawSetString(vELSTD[vehicleid][4], "OFF");
}
}
return 1;
}
Under
Код:
public OnVehicleSirenStateChange(playerid, vehicleid, newstate)
{
ToggleELSPanelItem(vehicleid, ELS_PANEL_SIREN);
return 1;
}
Re: GetVehicleParamsSirenState(vehicleid) : 2 possible bugs -
Kalcor - 18.04.2015
The wiki is wrong at this point. Anything involving "VehicleParams" has three values: VEHICLE_PARAMS_UNSET = -1, VEHICLE_PARAMS_OFF = 0, VEHICLE_PARAMS_ON = 1.
Re: GetVehicleParamsSirenState(vehicleid) : 2 possible bugs -
Chilli9434 - 18.04.2015
Yeah dont always rely on the wiki straight after a new update has been released!
Re: GetVehicleParamsSirenState(vehicleid) : 2 possible bugs -
zeax - 18.04.2015
Quote:
Originally Posted by Kalcor
The wiki is wrong at this point. Anything involving "VehicleParams" has three values: VEHICLE_PARAMS_UNSET = -1, VEHICLE_PARAMS_OFF = 0, VEHICLE_PARAMS_ON = 1.
|
What about the second report, why do I have to enable the sirens for the second time for it to detect as the vehicle sirens on?
Re: GetVehicleParamsSirenState(vehicleid) : 2 possible bugs -
MP2 - 18.04.2015
Quote:
Originally Posted by Kalcor
The wiki is wrong at this point. Anything involving "VehicleParams" has three values: VEHICLE_PARAMS_UNSET = -1, VEHICLE_PARAMS_OFF = 0, VEHICLE_PARAMS_ON = 1.
|
The page for GetVehicleParamsEx explains this, it was just missing off the GetVehicleParamsSirenState page. I've updated it.
Re: GetVehicleParamsSirenState(vehicleid) : 2 possible bugs -
Kalcor - 18.04.2015
Quote:
Originally Posted by zeax
What about the second report, why do I have to enable the sirens for the second time for it to detect as the vehicle sirens on?
|
Because of this bug:
https://sampforum.blast.hk/showthread.php?tid=571331
So you can wait for the next server update or do something like this:
pawn Код:
stock ToggleELSPanelItem(vehicleid, itemid, togglestate)
...
if(togglestate == VEHICLE_PARAMS_ON) TextDrawSetString(vELSTD[vehicleid][4], "~y~ON");
else TextDrawSetString(vELSTD[vehicleid][4], "OFF");
...
ToggleELSPanelItem(vehicleid, ELS_PANEL_SIREN, newstate);