Only allowes one siren ingame
#1

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;
    }
Reply
#2

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]"
Reply
#3

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


Forum Jump:


Users browsing this thread: 1 Guest(s)