new glob4;
new glob3;
CMD:siren(playerid, params[])
{
if(fInfo[playerid][fPolice] != 1) return SCM(playerid, COR_CINZA, "You are not a Police Officer.");
glob4 = GetPlayerVehicleID(playerid);
glob3 = CreateObject(18646, -0.7, 0.15, 0.85, 0.0, 0.0, 96.0, 0);
AttachObjectToVehicle(glob3, glob4, 0.014999, -0.379999, 0.914999, 0.000000, 0.000000, 0.000000);
SendClientMessage(playerid, COLOR_GREY, "You turned your siren on.");
return 1;
}
new SirenStatus[MAX_PLAYERS] = false;
CMD:siren(playerid, params[])
{
if(fInfo[playerid][fPolice] != 1) return SCM(playerid, COR_CINZA, "You are not a Police Officer.");
if(SirenStatus[playerid] == true) // Siren is already on
{
SirenStatus[playerid] = false; // The siren is on, so we turn it off.
// Place code here to turn off the siren
return SendClientMessage(playerid, COLOR_GREY, "You turned your siren off.");
}
SirenStatus[playerid] = true; // The siren is off, so we turn it on.
glob4 = GetPlayerVehicleID(playerid);
glob3 = CreateObject(18646, -0.7, 0.15, 0.85, 0.0, 0.0, 96.0, 0);
AttachObjectToVehicle(glob3, glob4, 0.014999, -0.379999, 0.914999, 0.000000, 0.000000, 0.000000);
SendClientMessage(playerid, COLOR_GREY, "You turned your siren on.");
return 1;
}
|
I would just create a variable 'SirenStatus' and use that to store and determine the siren status.
Код:
new SirenStatus[MAX_PLAYERS] = false;
CMD:siren(playerid, params[])
{
if(fInfo[playerid][fPolice] != 1) return SCM(playerid, COR_CINZA, "You are not a Police Officer.");
if(SirenStatus[playerid] == true) // Siren is already on
{
SirenStatus[playerid] = false; // The siren is on, so we turn it off.
// Place code here to turn off the siren
return SendClientMessage(playerid, COLOR_GREY, "You turned your siren off.");
}
SirenStatus[playerid] = true; // The siren is off, so we turn it on.
glob4 = GetPlayerVehicleID(playerid);
glob3 = CreateObject(18646, -0.7, 0.15, 0.85, 0.0, 0.0, 96.0, 0);
AttachObjectToVehicle(glob3, glob4, 0.014999, -0.379999, 0.914999, 0.000000, 0.000000, 0.000000);
SendClientMessage(playerid, COLOR_GREY, "You turned your siren on.");
return 1;
}
|
new VehSirenState[MAX_VEHICLES] = 0; //put this somewhere in the global variables, to check the state
new VehSirenObject[MAX_VEHICLES] = 0; //put this somewhere in the global variables to save the ojbect id to destroy.
CMD:siren(playerid, params[])
{
if(fInfo[playerid][fPolice] == 1)
{
if(IsPlayerInAnyVehicle(playerid))
{
new vehicleid = GetPlayerVehicleID(playerid);
if(VehSirenState[vehicleid] == 1)
{
VehSirenState[vehicleid] = 0;
DestroyDynamicObject(VehSirenObject[vehicleid]);
SendClientMessage(playerid, COLOR_GREY, "You have turned your siren OFF.");
return 1;
}
new type;
if(sscanf(params, "i", type))
{
SendClientMessage(playerid, COLOR_GRAY, "USAGE: /siren [Type]");
SendClientMessage(playerid, COLOR_WHITE, "Type: 1 = Dashboard, 2 = Outside");
return 1;
}
switch(type)
{
case 1:
{
VehSirenState[vehicleid] = 1;
VehSirenObject[vehicleid] = CreateDynamicObject(18646, 10.0, 10.0, 10.0, 0, 0, 0);
AttachDynamicObjectToVehicle(VehSirenObject[vehicleid], vehicleid, 0.0, 0.75, 0.275, 0.0, 0.1, 0.0);
SendClientMessage(playerid, COLOR_GREY, "You have turned on your dashboard siren.");
}
case 2:
{
VehSirenState[vehicleid] = 1;
new Float:properz;
switch(GetVehicleModel(vehicleid))
{
case 415: properz = 0.640;
case 541: properz = 0.660;
case 560: properz = 0.835;
case 598: properz = 0.835;
case 596 .. 597: properz = 0.880;
case 490: properz = 1.135;
case 599: properz = 1.035;
case 407: properz = 1.100;
case 427: properz = 1.100;
case 544: properz = 1.100;
default: properz = 0.780;
}
new Float:propery;
switch(GetVehicleModel(facvehicleid))
{
case 407: propery = 0.9;
case 427: propery = 0.8;
case 544: propery = 0.9;
default: propery = 0.0;
}
VehSirenObject[vehicleid] = CreateDynamicObject(18646, 10.0, 10.0, 10.0, 0, 0, 0);
AttachDynamicObjectToVehicle(VehSirenObject[vehicleid], vehicleid, -0.43, propery, properz, 0.0, 0.1, 0.0);
SendClientMessage(playerid, COLOR_GREY, "You have turned out the siren outside.");
}
default:
{
SendClientMessage(playerid, COLOR_GRAY, "Unknown type! /siren [Type]");
SendClientMessage(playerid, COLOR_WHITE, "Type: 1 = Dashboard, 2 = Outside");
}
}
}
else return SCM(playerid, COLOR_GRAY, "You are not driving a car.");
}
else return SendClientMessage(playerid, COLOR_GRAY, "You're not a law enforcement officer.");
return 1;
}