i am trying to redo a siren command i got and i am having trouble with the system of it
Код:
CMD:siren(playerid, params[])
{
//if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
//if(!IsACop(playerid) && !IsAHSF(playerid) && !IsASWAT(playerid) && !IsASATF(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You are not an LSPD/HSF Member.");
if (GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, -1, "You are not the vehicle driver");
new pveh = GetPlayerVehicleID(playerid);
if (!GetVehicleModel(pveh)) return SendClientMessage(playerid, -1, "You are not inside a vehicle");
if (VObject5(obj1[pveh])) return SendClientMessage(playerid, -1, "You switched your siren off"), DObject5(obj1[pveh]);
if (VObject4(obj2[pveh])) return SendClientMessage(playerid, -1, "You switched your siren off"), DObject4(obj2[pveh]);
if (VObject3(obj3[pveh])) return SendClientMessage(playerid, -1, "You switched your siren off"), DObject3(obj3[pveh]);
switch (GetVehicleModel(pveh))
{
//19419 - Lightbar, ***18646 - Dash***, 19292 - blue flash, 19294 - yellow flash, 19290 red flash
case 560:
{
obj1[pveh] = CObject5(19797, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
AObject5(obj1[pveh], pveh, -0.2500000, 2.6000000, 0.06, 0.000000, 0.000000, 180.000000);
obj2[pveh] = CObject4(19797, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
AObject4(obj2[pveh], pveh, 0.2500000, 2.6000000, 0.06, 0.000000, 0.000000, 180.000000);
obj3[pveh] = CObject3(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
AObject3(obj3[pveh], pveh, 0.000000, 1.7000000, 0.0, 0.000000, 0.000000, 0.000000);
}
default:
{
return SendClientMessage(playerid, -1, "* You are not in an emergency vehicle!");
}
}
return SendClientMessage(playerid, -1, "Siren activated");
}
Basically when i do /siren in game it spawns them all but when i do it again it only destroys one object so i have to type /siren 3 times to remove them all is there anything i can change it to make it destroy all 3 objects at once?
you're returning everytime when player types command with a message "You switched your siren off".
if u dont want to change your code, u can simply add a variable which detects to return automatically.
PHP код:
new pveh = GetPlayerVehicleID(playerid), mustreturn = 0;
if (!GetVehicleModel(pveh)) return SendClientMessage(playerid, -1, "You are not inside a vehicle");
if (VObject5(obj1[pveh])) SendClientMessage(playerid, -1, "You switched your siren off"), DObject5(obj1[pveh]), mustreturn = 1;
if (VObject4(obj2[pveh])) SendClientMessage(playerid, -1, "You switched your siren off"), DObject4(obj2[pveh]), mustreturn = 1;
if (VObject3(obj3[pveh])) SendClientMessage(playerid, -1, "You switched your siren off"), DObject3(obj3[pveh]), mustreturn = 1;
if(mustreturn) return 1;
P.S. this will cause 3-time flood message with text "You switched your siren off", u can simply edit this code too.