SA-MP Forums Archive
Only allowes one siren ingame - 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 allowes one siren ingame (/showthread.php?tid=464442)



Only allowes one siren ingame - Don_Cage - 16.09.2013

Hello.
I made this command and went inside the server to test it. When my friend came online we noticed that when the other puts on his siren the other ones dissapears. Here is the code..
pawn Код:
if(!strcmp(cmd,"/siren",true))
    {
        if(IsACop(playerid))
        {
            new carid = GetPlayerVehicleID(playerid);
            new x_nr[24];
            x_nr = strtok(cmdtext, idx);
            if(!strlen(x_nr))
            {
                SendClientMessage(playerid, COLOR_GREY, "USAGE: /siren [type]");
                SendClientMessage(playerid, COLOR_GREY, "Types: Inside, Roof, Off.");
                return 1;
            }
            if(!strcmp(x_nr,"inside",true))
            {
                DestroyObject(SirenObject[carid]);
                SirenObject[carid] = CreateObject(18646, 10.0, 10.0, 10.0, 0, 0, 0);
                AttachObjectToVehicle(SirenObject[carid], carid, 0.0, 0.75, 0.275, 0.0, 0.1, 0.0);
                Siren[carid] = 1;
                format(string, sizeof(string), "* Law Enforcer puts the siren on the dashboard.");
                ProxDetector(30.0, playerid, string, COLOR_RLRPGBLUE,COLOR_RLRPGBLUE,COLOR_RLRPGBLUE,COLOR_RLRPGBLUE,COLOR_RLRPGBLUE);
                return 1;
            }
            if(!strcmp(x_nr,"roof",true))
            {
                DestroyObject(SirenObject[carid]);
                SirenObject[carid] = CreateObject(18646, 10.0, 10.0, 10.0, 0, 0, 0);
                AttachObjectToVehicle(SirenObject[carid], carid, -0.43, 0.0, 0.785, 0.0, 0.1, 0.0);
                Siren[carid] = 1;
                format(string, sizeof(string), "* Law Enforcer puts the siren on the roof.");
                ProxDetector(30.0, playerid, string, COLOR_RLRPGBLUE,COLOR_RLRPGBLUE,COLOR_RLRPGBLUE,COLOR_RLRPGBLUE,COLOR_RLRPGBLUE);
                return 1;
            }
            if(!strcmp(x_nr,"off",true))
            {
                if(Siren[carid] == 1)
                {
                    Siren[carid] = 0;
                    DestroyObject(SirenObject[carid]);
                    format(string, sizeof(string), "* Law Enforcer takes down the siren.");
                    ProxDetector(30.0, playerid, string, COLOR_RLRPGBLUE,COLOR_RLRPGBLUE,COLOR_RLRPGBLUE,COLOR_RLRPGBLUE,COLOR_RLRPGBLUE);
                    return 1;
                }
                else
                {
                    SendClientMessage(playerid, COLOR_GRAD1,"This vehicle does not have a siren on!");
                    return 1;
                }
            }
        }
        else
        {
            SendClientMessage(playerid, COLOR_GREY,"You are not authorized to use this command.");
            return 1;
        }
        return 1;
    }



Re: Only allowes one siren ingame - alinategh - 17.09.2013

Maybe you're both using one car model...
Problem is the format of your "Siren" variable, you could make it like "Siren[MAX_PLAYERS][carid]"


Re: Only allowes one siren ingame - Don_Cage - 17.09.2013

I have the variables like this
pawn Код:
new Siren[MAX_VEHICLES];
new SirenObject[MAX_VEHICLES];