SA-MP Forums Archive
OnVehicleSirenStateChange for specific vehicles - 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: OnVehicleSirenStateChange for specific vehicles (/showthread.php?tid=610072)



OnVehicleSirenStateChange for specific vehicles - DemME - 19.06.2016

Is it possible? or I should've to do it manually through the script via AddStaticVehicle?

Quote:

public OnVehicleSirenStateChange(playerid, vehicleid, newstate)
{
new siren = GetVehicleParamsSirenState(vehicleid);
if(siren == 1)
{
static
Float:fSize[3],
Float:fSeat[3];

GetVehicleModelInfo(GetVehicleModel(vehicleid), VEHICLE_MODEL_INFO_SIZE, fSize[0], fSize[1], fSize[2]); // need height (z)
GetVehicleModelInfo(GetVehicleModel(vehicleid), VEHICLE_MODEL_INFO_FRONTSEAT, fSeat[0], fSeat[1], fSeat[2]); // need pos (x, y)

CoreVehicles[vehicleid][vehSirenOn] = 1;
CoreVehicles[vehicleid][vehSirenObject] = CreateDynamicObject(18646, 0.0, 0.0, 1000.0, 0.0, 0.0, 0.0);

AttachDynamicObjectToVehicle(CoreVehicles[vehicleid][vehSirenObject], vehicleid, -fSeat[0], fSeat[1], fSize[2] / 2.0, 0.0, 0.0, 0.0);
InfoBoxForPlayer(playerid, "~w~Siren lights: ~g~ ON");
}
else
{
CoreVehicles[vehicleid][vehSirenOn] = 0;
DestroyDynamicObject(CoreVehicles[vehicleid][vehSirenObject]);
InfoBoxForPlayer(playerid, "~w~Siren lights: ~r~ OFF");
}
return 1;
}
That's my code above but it turns to any vehicle that has a siren, is it possible to strict it only to cheetah, sultan or premier?


Re: OnVehicleSirenStateChange for specific vehicles - Konstantinos - 19.06.2016

pawn Код:
public OnVehicleSirenStateChange(playerid, vehicleid, newstate)
{
    switch (GetVehicleModel(vehicleid))
    {
        case 415, 426, 560:
        {
            // code..
        }
    }
    return 1;
}
If the model of the vehicle is one of those three, do some stuff.