Locker problem rep
#1

pawn Код:
CMD:testlocker(playerid, params[])
{
    new string[256], iFac = arrFaction[playerid][g_iFactionID];
    if(arrFaction[playerid][p_iMember] > 0)
    {
        if(arrFaction[iFac][g_iLockerGuns] == 0)
        {
            SendClientMessage(playerid, COLOR_WHITE, "Your faction lockers have no weapons in them!");
        }
        if(arrFaction[iFac][g_iLockerGuns] > 0)
        {
            [B][U]new str[24];GetWeaponName(arrFaction[iFac][g_iLockerGuns], str, sizeof(str))[/U][/B];
            format(string, sizeof(string), "%s - $%i", str, arrFaction[iFac][g_iLockerCost]);
            ShowPlayerDialog(playerid, DIALOG_FACWEPS, DIALOG_STYLE_LIST, "Faction Locker", string, "Select", "Cancel");
        }
    }
    else SendClientMessage(playerid, COLOR_WHITE, "You are not in a faction!");
    return 1;
}
Basically, whenever I set lockerGuns 1 to an ID it doesnt pick it up.
Probably why:
pawn Код:
CMD:editweapons(playerid, params[])
{
    new string[128], wepslot, weaponID, iFac = arrFaction[playerid][g_iFactionID];
    if(PlayerInfo[playerid][pAdmin] >= 5)
    {
        if(sscanf(params, "id", wepslot, weaponID)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /editweapons [wepslot] [wepid]");
       
        if(wepslot == 1)
        {
            [B]arrFaction[iFac][g_iLockerGuns][U][1][/U] = weaponID;[/B]
            format(string, sizeof(string), "You have changed %s's weapon slot 1 to weapon ID %d.", arrFaction[iFac][g_szFactionName], weaponID);
            SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
        }
    }
    return 1;
}
I underlined the problem the number and made the line bold.

I am setting the locker gun 1 to an ID but on my testlocker cmd its not looking for all the guns, my enum:
Quote:

g_iLockerGuns[16],

So how can I do this? Because when I add the [16] on the end of the :testlocker thing(highlighted and bolded it) it gives me an error

thanks

+rep
Reply
#2

PHP код:
CMD:editweapons(playeridparams[])
{
    new 
string[128], wepslotweaponIDiFac arrFaction[playerid][g_iFactionID];
    if(
PlayerInfo[playerid][pAdmin] >= 5)
    {
        if(
sscanf(params"id"wepslotweaponID)) return SendClientMessage(playeridCOLOR_WHITE"USAGE: /editweapons [wepslot] [wepid]");
        
arrFaction[iFac][g_iLockerGuns][wepslot] = weaponID;
        
format(stringsizeof(string), "You have changed %s's weapon slot 1 to weapon ID %d."arrFaction[iFac][g_szFactionName], weaponID);
        
SendClientMessage(playeridCOLOR_LIGHTBLUEstring);
    }
    return 
1;

I have no idea what you said, but I'm guessing this is what you are getting at.
Reply
#3

Didn't work, basically there is 16 slots in the locker and when I do my /editweapons CMD and set slot 3 to ID 24 for eg, and then I do /testlocker it says there are no guns in there locker because its only looking for gun ID 1, so how can i fix this?
Reply
#4

Try with this:
PHP код:
CMD:testlocker(playeridparams[])
{
    new 
string[256], iFac arrFaction[playerid][g_iFactionID];
    if(
arrFaction[playerid][p_iMember] > 0)
    {
        if(
arrFaction[iFac][g_iLockerGuns][1] == 0)
        {
            
SendClientMessage(playeridCOLOR_WHITE"Your faction lockers have no weapons in them!");
        }
        if(
arrFaction[iFac][g_iLockerGuns][1] > 0)
        {
            new 
str[24];GetWeaponName(arrFaction[iFac][g_iLockerGuns][1], strsizeof(str));
            
format(stringsizeof(string), "%s - $%i"strarrFaction[iFac][g_iLockerCost][1]);
            
ShowPlayerDialog(playeridDIALOG_FACWEPSDIALOG_STYLE_LIST"Faction Locker"string"Select""Cancel");
        }
    }
    else 
SendClientMessage(playeridCOLOR_WHITE"You are not in a faction!");
    return 
1;

Reply
#5

Thats only looking if weapon slot 1 has a gun, I need it to get all 16 weapon slots

so the dialog would be like

*wepname here* - *price* - wep 1
*wepname here* - *price* - wep 2
*wepname here* - *price* - wep 3
*wepname here* - *price* - wep 4
*wepname here* - *price* - wep 5
*wepname here* - *price* - wep 6

etc, in a dialog up to 16
Reply
#6

You need to use a loop
PHP код:
CMD:testlocker(playeridparams[])
{
    new 
string[256], iFac arrFaction[playerid][g_iFactionID];
    if(
arrFaction[playerid][p_iMember] > 0)
    {
        for(new 
016i++)
        {
            if(
arrFaction[iFac][g_iLockerGuns][i] > 0)
            {
                new 
str[24];GetWeaponName(arrFaction[iFac][g_iLockerGuns][i], strsizeof(str));
                
format(stringsizeof(string), "%s %s - $%i\n"stringstrarrFaction[iFac][g_iLockerCost][i]);
                
ShowPlayerDialog(playeridDIALOG_FACWEPSDIALOG_STYLE_LIST"Faction Locker"string"Select""Cancel");
            }
        }
    }
    else 
SendClientMessage(playeridCOLOR_WHITE"You are not in a faction!");
    return 
1;

Reply
#7

That worked, thanks so much!!!

EDIT: Fixed it

On my dialog response, it doesnt do anything?

pawn Код:
if(dialogid == DIALOG_FACWEPS)
    {
        if(response)
        {
            if(listitem == 0)
            {
                new iFac = arrFaction[playerid][g_iFactionID];
                new weaponid = arrFaction[iFac][g_iLockerGuns];
                new gunamount = arrFaction[iFac][g_iLockerCost];
                GivePlayerWeapon(playerid, weaponid, 9999);
                format(string, sizeof(string), "You have received weapon ID: %i, it cost $%i.", arrFaction[iFac][g_iLockerGuns], gunamount);
                GivePlayerMoney(playerid, -gunamount);
            }
            if(listitem == 1)
            {
                new iFac = arrFaction[playerid][g_iFactionID];
                new weaponid = arrFaction[iFac][g_iLockerGuns];
                GivePlayerWeapon(playerid, weaponid, 9999);
                format(string, sizeof(string), "You have received weapon ID: %i", arrFaction[iFac][g_iLockerGuns]);
            }
            if(listitem == 2)
            {
                new iFac = arrFaction[playerid][g_iFactionID];
                new weaponid = arrFaction[iFac][g_iLockerGuns];
                GivePlayerWeapon(playerid, weaponid, 9999);
                format(string, sizeof(string), "You have received weapon ID: %i", arrFaction[iFac][g_iLockerGuns]);
            }
        }
    }
I have only added in 3 guns on the response but it doesnt give me any of them
Reply
#8

Try it
PHP код:
if(dialogid == DIALOG_FACWEPS)
    {

        if(
response)
        {
            new 
choice = -1;
            for(new 
016i++)
            {
                if(
arrFaction[iFac][g_iLockerGuns][i] > 0choice++
                if(
listitem == choice)
                {
                    new 
iFac arrFaction[playerid][g_iFactionID];
                        new 
weaponid arrFaction[iFac][g_iLockerGuns][i];
                    new 
gunamount arrFaction[iFac][g_iLockerCost][i];
                    
GivePlayerWeapon(playeridweaponid9999);
                    
format(stringsizeof(string), "You have received weapon ID: %i, it cost $%i."arrFaction[iFac][g_iLockerGuns][i], gunamount);
                    
GivePlayerMoney(playerid, -gunamount);
                }
            }
        }
    } 
Rep + ?
Reply
#9

Worked thanks! rep'd
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)