In the /on command you need to create the disco lights with CreateObject(...)
And in the /off command you destroy them with DestroyObject(...)
--- Example ---
You could create a toggle function
PHP код:
ToggleDiscoLights(toggle) {
enum eDiscoLight {
eDL_modelid,
Float: eDL_X,
Float: eDL_Y,
Float: eDL_Z,
Float: eDL_rX,
Float: eDL_rY,
Float: eDL_rZ,
eDL_objectid
};
static sDiscoLight[][eDiscoLight] = {
// change / add here your disco lights
{18647, 0.0, 1.0, 2.0, 5.0, 6.0, 7.0},
{18647, 0.0, 1.0, 2.0, 5.0, 6.0, 7.0}
};
if(toggle) {
if(sDiscoLight[0][eDL_objectid] != 0) {
return false;
}
for(new i; i < sizeof sDiscoLight; ++i) {
sDiscoLight[i][eDL_objectid] = CreateObject(sDiscoLight[i][eDL_modelid], sDiscoLight[i][eDL_X], sDiscoLight[i][eDL_Y], sDiscoLight[i][eDL_Z], sDiscoLight[i][eDL_rX], sDiscoLight[i][eDL_rY], sDiscoLight[i][eDL_rZ]);
}
} else {
if(sDiscoLight[0][eDL_objectid] == 0) {
return false;
}
for(new i; i < sizeof sDiscoLight; ++i) {
DestroyObject(sDiscoLight[i][eDL_objectid]);
}
sDiscoLight[0][eDL_objectid] = 0;
}
return true;
}
and use it in your commands (zcmd)
PHP код:
// OnGameModeInit - if you want them to be by default on
ToggleDiscoLights(true);
CMD:on(playerid, params[]) {
if(!ToggleDiscoLights(true)) {
return SendClientMessage(playerid, -1, "Disco lights are already on!");
}
return true;
}
CMD:off(playerid, params[]) {
if(!ToggleDiscoLights(false)) {
return SendClientMessage(playerid, -1, "Disco lights are already off!");
}
return true;
}
You need to remove the objects from the map itself otherwise they would be duplicated