#define FILTERSCRIPT // This is to define the script as a FS #include <a_samp> #include <zcmd> #include <sscanf2> #include <foreach> #define MAX_DYNAMIC_CARS 500 // If this isn't already in your script, add it enum VehicleSirenInfo { EmergencyCopSiren } new VehicleInfo[MAX_DYNAMIC_CARS][VehicleSirenInfo]; // If a player moves out of the area, the siren will turn off (not fade out), and if they enter the zone with the siren again, it'll // start the siren audio over again. stock InAreaWithCopSiren(playerid) // This is to check if a player is in the area with the siren audio { new Float:x, Float:y, Float:z; for(new i = 0; i < MAX_DYNAMIC_CARS; i ++) { GetVehiclePos(i, x, y, z); if(IsPlayerInRangeOfPoint(playerid, 100.0, x, y, z)) { if(VehicleInfo[i][EmergencyCopSiren] != 0) { SetPVarFloat(playerid, "CopSirenX", x); SetPVarFloat(playerid, "CopSirenY", y); SetPVarFloat(playerid, "CopSirenZ", z); return 1; } } } return false; } public OnPlayerUpdate(playerid) { if(InAreaWithCopSiren(playerid)) { if(!GetPVarInt(playerid, "CopSiren")) { SetPVarInt(playerid,"CopSiren", 1); new link[128]; format(link, 128, "https://falcon-host.org/uploads/siren.mp3"); // This is the siren which I made and merged, but you can change it. PlayAudioStreamForPlayer(playerid, link, GetPVarFloat(playerid, "CopSirenX"), GetPVarFloat(playerid, "CopSirenY"), GetPVarFloat(playerid, "CopSirenZ"), 100.0 , 0); } } else { if(GetPVarInt(playerid, "CopSiren") != 0) { DeletePVar(playerid, "CopSiren"); StopAudioStreamForPlayer(playerid); } } return 1; } // This is mandatory because if several emergency cars are in the area at the same time, and the player disconnects, the siren will be turned off. // It is also added to prevent bugs from occurring, to restart the server over and over. public OnPlayerDisconnect(playerid, reason) { if(IsPlayerInAnyVehicle(playerid)) { new Float:x, Float:y, Float:z; new VehicleID = GetPlayerVehicleID(playerid); if(VehicleInfo[VehicleID][EmergencyCopSiren] != 0) { GetVehiclePos(VehicleID, x, y, z); VehicleInfo[VehicleID][EmergencyCopSiren] = 0; foreach(new i : Player) { if(IsPlayerInRangeOfPoint(i, 100.0, x, y, z)) { if(GetPVarInt(i, "CopSiren") != 0) { StopAudioStreamForPlayer(i); SetPVarInt(i, "CopSiren", 0); } } } } } return 1; } public OnVehicleDeath(vehicleid, killerid) { if(VehicleInfo[vehicleid][EmergencyCopSiren] != 0) { new Float:x, Float:y, Float:z; GetVehiclePos(vehicleid, x, y, z); foreach(new i : Player) { if(IsPlayerInRangeOfPoint(i, 100.0, x, y, z)) { if(GetPVarInt(i,"CopSiren") != 0) { StopAudioStreamForPlayer(i); SetPVarInt(i, "CopSiren", 0); } } } VehicleInfo[vehicleid][EmergencyCopSiren] = 0; } return 1; } // This is the command to be used: /siren on = turns on the siren, and /siren off = turns it off. CMD:siren(playerid, params[]) { new Float:x, Float:y, Float:z, VehicleID, option[16]; if(sscanf(params, "s[16]", option)) { SendClientMessage(playerid, 0xFF6347FF, "Usage: /siren [parameter]"); SendClientMessage(playerid, 0xFF6347FF, "Parameters: {FFFFFF}on, off"); return true; } if(strcmp(option, "on", true) == 0) { VehicleID = GetPlayerVehicleID(playerid); GetVehiclePos(VehicleID, x, y, z); new link[128]; format(link, 128, "https://falcon-host.org/uploads/siren.mp3"); foreach(new i : Player) { if(IsPlayerInRangeOfPoint(i, 100.0, x, y, z)) { PlayAudioStreamForPlayer(i, link, x, y, z, 100.0, 0); SetPVarInt(i, "CopSiren", 1); } } VehicleInfo[VehicleID][EmergencyCopSiren] = 1; // 1 = true } if(strcmp(option, "off", true) == 0) { VehicleID = GetPlayerVehicleID(playerid); GetVehiclePos(VehicleID, x, y, z); foreach(new i : Player) { if(IsPlayerInRangeOfPoint(i, 100.0, x, y, z)) { if(GetPVarInt(i,"CopSiren") != 0) { StopAudioStreamForPlayer(i); SetPVarInt(i, "CopSiren", 0); } } } VehicleInfo[VehicleID][EmergencyCopSiren] = 0; // 0 = not true } return 1; }
where demo? |
#define MAX_DYNAMIC_CARS 500 // If this isn't already in your script, add it
enum VehicleSirenInfo { EmergencyCopSiren }
stock InAreaWithCopSiren(playerid) // This is to check if a player is in the area with the siren audio { new Float:x, Float:y, Float:z; for(new i = 0; i < MAX_DYNAMIC_CARS; i ++) { GetVehiclePos(i, x, y, z); if(IsPlayerInRangeOfPoint(playerid, 100.0, x, y, z)) { if(VehicleInfo[i][EmergencyCopSiren] != 0) { SetPVarFloat(playerid, "CopSirenX", x); SetPVarFloat(playerid, "CopSirenY", y); SetPVarFloat(playerid, "CopSirenZ", z); return 1; } } } return false; }
public OnPlayerUpdate(playerid)
format(link, 128, "https://falcon-host.org/uploads/siren.mp3"); // This is the siren which I made and merged, but you can change it.