PDA

View Full Version : Only one siren allowed on server


lramos15
02/08/2013, 06:40 PM
When I do /siren it shows a siren and when someone else does it takes my siren off it wont allow 2 sirens on the server
new myobject[MAX_PLAYERS];
CMD:siren(playerid, params[])
{
if(!IsValidObject(myobject[playerid]))
{
if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 560 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 415 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 541)
{
myobject[playerid] = CreateObject(18646,0,0,-1000,0,0,0,100);
AttachObjectToVehicle(myobject[playerid], GetPlayerVehicleID(playerid), 0.449999,0.000000,0.599999,0.000000,0.000000,0.000 000);
}
}
else
{
DestroyObject(myobject[playerid]);
}
return 1;
}

Dokins
02/08/2013, 06:43 PM
I guess that your object limit has been reached. I suggest using a AttachDynamicObjectToVehicle etc and find a new streamer!

SMCentral
02/08/2013, 06:48 PM
There are two possible issues:

a) myobject[playerid] is not being reset when a player disconnects so someone else connects and has someone's siren and when they use /siren it destroys it
b) You should use a streamer ideally because of the post above

lramos15
02/08/2013, 07:33 PM
I have like 20 objects, also I restart the server so the disconnect thing doesn't seem to be valid. I'm confused why it's not working.

Facerafter
02/08/2013, 09:36 PM
I use

new Siren[MAX_VEHICLES];
new SirenObject[MAX_VEHICLES];


CMD:siren(playerid, params[])
{
new siren[65];
new VID = GetPlayerVehicleID(playerid);
new string[128];
if(strcmp(siren, "inside", true, strlen(siren)) == 0)
{
if(Siren[VID] == 0)
{
Siren[VID] = 1;
SirenObject[VID] = CreateObject(18646, 10.0, 10.0, 10.0, 0, 0, 0);
AttachObjectToVehicle(SirenObject[VID], VID, 0.0, 0.75, 0.275, 0.0, 0.1, 0.0);
format(string, sizeof(string), "* %s puts the siren on the dashboard.", GetPlayerNameEx(playerid));
SendNearbyMessage(playerid, 30, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPL E,COLOR_PURPLE);
}
else
{
return SendClientMessage(playerid, COLOR_GREY, "This vehicle already has a siren!");
}
}
}
return 1;
And works fine.
You can use this code. Or try to use [MAX_VEHICLES] instead of [MAX_PLAYERS]

lramos15
16/08/2013, 07:17 PM
so [MAX_VEHICLES] worked for a little now it suddenly stopped working any other ideas?

yusei
16/08/2013, 07:37 PM
use the following :

new myobject[MAX_PLAYERS];
new bool: siren[MAX_PLAYERS];

CMD:siren(playerid, params[])
{
if(siren[playerid] == false)
{
if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 560 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 415 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 541)
{
myobject[playerid] = CreateObject(18646,0,0,-1000,0,0,0,100);
AttachObjectToVehicle(myobject[playerid], GetPlayerVehicleID(playerid), 0.449999,0.000000,0.599999,0.000000,0.000000,0.000 000);
siren[playerid] = true;
return 1;
}
}
if(siren[playerid] == true)
{
DestroyObject(myobject[playerid]);
siren[playerid] = false;
return 1;
}
return 1;
}