Only one siren allowed on server
#1

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
Код HTML:
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.000000);
         }
    }
    else
    {
        DestroyObject(myobject[playerid]);
    }
    return 1;
}
Reply
#2

I guess that your object limit has been reached. I suggest using a AttachDynamicObjectToVehicle etc and find a new streamer!
Reply
#3

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
Reply
#4

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.
Reply
#5

I use
pawn Код:
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_PURPLE,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]
Reply
#6

so [MAX_VEHICLES] worked for a little now it suddenly stopped working any other ideas?
Reply
#7

use the following :

PHP код:
new myobject[MAX_PLAYERS];
new 
boolsiren[MAX_PLAYERS];
CMD:siren(playeridparams[])
{
    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.000000);
            
siren[playerid] = true;
            return 
1;
        }
    }
    if(
siren[playerid] == true)
    {
        
DestroyObject(myobject[playerid]);
        
siren[playerid] = false;
        return 
1;
    }
    return 
1;

Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)