SA-MP Forums Archive
Vehicle Siren? - 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: Vehicle Siren? (/showthread.php?tid=573907)



Vehicle Siren? - cordellpwnz - 11.05.2015

Is it true I can make a siren sound on a vehicle? If so, will this command work?

I put the code on this copy and baste bin:
http://pastebin.com/9ZsfYpJA


Re: Vehicle Siren? - Luis- - 11.05.2015

You'd also need to make use of this function.

pawn Код:
OnVehicleSirenStateChange(playerid, vehicleid, newstate)
Also, here, a little fix.
pawn Код:
CMD:togglesiren(playerid, params[])
{
new siren = GetVehicleParamsSirenState(vehicleid);
    if(IsACop(playerid) || IsAHitman(playerid) || IsAGovernment(playerid))
    {
        if(siren == 1)
        {
            siren = 0
            SendClientMessageEx(playerid, COLOR_WHITE, "Siren disabled.");
            return 1;
        }
        else
        {
            siren = 1
            SendClientMessageEx(playerid, COLOR_WHITE, "Siren enabled.");
            return 1;
        }
        SendClientMessage(playerid, COLOR_GRAD2, "This vehicle does not support mounted sirens.");
    }
    return 1;
}



Re: Vehicle Siren? - cordellpwnz - 11.05.2015

Quote:
Originally Posted by Luis-
Посмотреть сообщение
You'd also need to make use of this function.

pawn Код:
OnVehicleSirenStateChange(playerid, vehicleid, newstate)
Also, here, a little fix.
pawn Код:
CMD:togglesiren(playerid, params[])
{
new siren = GetVehicleParamsSirenState(vehicleid);
    if(IsACop(playerid) || IsAHitman(playerid) || IsAGovernment(playerid))
    {
        if(siren == 1)
        {
            siren = 0
            SendClientMessageEx(playerid, COLOR_WHITE, "Siren disabled.");
            return 1;
        }
        else
        {
            siren = 1
            SendClientMessageEx(playerid, COLOR_WHITE, "Siren enabled.");
            return 1;
        }
        SendClientMessage(playerid, COLOR_GRAD2, "This vehicle does not support mounted sirens.");
    }
    return 1;
}
I don't know how to script, do you have team viewer or something you can use to help me?


Re: Vehicle Siren? - MP2 - 11.05.2015

You do realise that code isn't actually setting a siren, right? You need to set the last parameter of AddStaticVehicleEx or CreateVehicle to 1 to give vehicles a siren.

https://sampwiki.blast.hk/wiki/CreateVehicle


Re: Vehicle Siren? - cordellpwnz - 11.05.2015

Quote:
Originally Posted by MP2
Посмотреть сообщение
You do realise that code isn't actually setting a siren, right? You need to set the last parameter of AddStaticVehicleEx or CreateVehicle to 1 to give vehicles a siren.

https://sampwiki.blast.hk/wiki/CreateVehicle
So I change the 0 beside faction respawn to 1?

LSPDVehicles[25] = AddStaticVehicleEx(560,1562.7063,-1693.5046,5.5956,181.0911,0,0, FACTION_RESPAWN);


Re: Vehicle Siren? - Luis- - 11.05.2015

pawn Код:
LSPDVehicles[25] = AddStaticVehicleEx(560,1562.7063,-1693.5046,5.5956,181.0911,0,0, FACTION_RESPAWN, 1);
https://sampwiki.blast.hk/wiki/GetVehicleParamsSirenState
https://sampwiki.blast.hk/wiki/OnVehicleSirenStateChange

It's pretty simple if you think about it.


Re: Vehicle Siren? - MP2 - 11.05.2015

Also, if you want to toggle the siren on/off, I think you can use the 'alarm' parameter of SetVehicleParamsEx. Someone told me that but I've yet to test it.


Re: Vehicle Siren? - cordellpwnz - 11.05.2015

Quote:
Originally Posted by Luis-
Посмотреть сообщение
pawn Код:
LSPDVehicles[25] = AddStaticVehicleEx(560,1562.7063,-1693.5046,5.5956,181.0911,0,0, FACTION_RESPAWN, 1);
https://sampwiki.blast.hk/wiki/GetVehicleParamsSirenState
https://sampwiki.blast.hk/wiki/OnVehicleSirenStateChange

It's pretty simple if you think about it.
I got that one now, but how do I add it on a mysql database? I'll post you screenshots below.
http://gyazo.com/6b5a615a416aa791888e5440a55f0f09
http://gyazo.com/028fc7bd37c1bd00b67697b4285ef488
http://gyazo.com/4bd6f6a27840f7d81110666f6415ce90
http://gyazo.com/62bc4374b06619b37f68b4ea9ab7b6f2


Re: Vehicle Siren? - The__ - 11.05.2015

Quote:
Originally Posted by cordellpwnz
Посмотреть сообщение
This is something I've did in my script when loading the vehicles. You dont need to define if it has a siren or not in your MySQL database - just check for faction.

pawn Код:
if(cardata[vehicleid][pFaction] == FACTION_POLICE)
    {
        //createvehicle with siren
    }
    else
    {
        // create vehicle no siren.
    }