SA-MP Forums Archive
Only one siren allowed on server - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Only one siren allowed on server (/showthread.php?tid=455655)



Only one siren allowed on server - lramos15 - 02.08.2013

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;
}



Re: Only one siren allowed on server - Dokins - 02.08.2013

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


Re: Only one siren allowed on server - SMCentral - 02.08.2013

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


Re: Only one siren allowed on server - lramos15 - 02.08.2013

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.


Re: Only one siren allowed on server - Facerafter - 02.08.2013

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]


Re: Only one siren allowed on server - lramos15 - 16.08.2013

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


Re : Only one siren allowed on server - yusei - 16.08.2013

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;