Array Help.
#1

PHP код:
enum EEquipInfo {
    
EEquipName[32],
    
EEquipFaction,
    
EEquipMinRank,
    
EEquipGun1,
    
EEquipGun2,
    
EEquipGun3,
    
EEquipGun4,
    
EEquipGun5,
    
EEquipGun6,
    
EEquipGun7,
    
EEquipGun8,
    
EEquipGun9,
    
EEquipGun10,
    
EEquipGun11,
    
EEquipGun12,
    
ESWATENABLE,
};
new 
EquipSlots[][EEquipInfo] = {
    
// LSPD
    
{"Recruit",                  1,  1,       3, 23, 41, 0,  0,    0,  0, 0, 0, 0, 0, 0, 0},
    {
"Probationary Trooper",  1,  2,       3, 23, 25, 41, 0,    0,  0, 0, 0, 0, 0, 0, 0},
    {
"Trooper",                  1,  3,      3, 24, 25, 41, 0,    0,  0, 0, 0, 0, 0, 0, 0},
    {
"Trooper First Class",   1,  4,      3, 24, 25, 29, 41,   0,  0, 0, 0, 0, 0, 0, 0},
    {
"Corporal",               1,  5,      3, 24, 25, 29, 41,   0,  0, 0, 0, 0, 0, 0, 0},
    {
"Detective I",            1,  6,      3, 24, 25, 29, 41,   0,  0, 0, 0, 0, 0, 0, 0},
    {
"Sergeant",                1,  7,      3, 24, 25, 29, 31,  41,  0, 0, 0, 0, 0, 0, 0},
    {
"Detective II",            1,  8,      24, 43,  0,  0,  0,  0, 0,  0, 0, 0, 0, 0, 0},
    {
"Sergeant First Class",  1,  9,      3,  24, 25, 29, 31, 41,  0, 0, 0, 0, 0, 0, 0},
    {
"Detective III",            1,  10,     24, 29, 43,  0,  0,  0,  0, 0, 0, 0, 0, 0, 0},
    {
"Lieutenant",            1,  11,     3,  24, 25, 29, 31, 41,  0, 0, 0, 0, 0, 0, 0},
    {
"Captain",                1,  12,     3,  24, 25, 29, 31, 41,  0, 0, 0, 0, 0, 0, 0},
    {
"Major",                    1,  13,     3,  24, 25, 29, 31, 41,  0, 0, 0, 0, 0, 0, 0},
    {
"Assistant Director",    1,  14,     3,  24, 25, 29, 31, 41,  0, 0, 0, 0, 0, 0, 0},
    {
"Deputy Director",        1,  15,     3,  24, 25, 29, 31, 41,  0, 0, 0, 0, 0, 0, 0},
    {
"Director",                   1,  16,     3,  24, 27, 29, 31, 41,  0, 0, 0, 0, 0, 0, 0},
    {
"SWAT EQUIPMENT",          1,  3,       24, 27, 29, 31, 34, 41,  0, 0, 0, 0, 0, 0, 1},
    
// FBI
    
{"Agent",                2,  1,     3, 24, 43,  0,  0,  0,  0,  0, 0, 0, 0, 0, 0},
    {
"Tactical (MP5)",      2,  2,    3, 24, 29,  0,  0,  0,  0,  0, 0, 0, 0, 0, 0},
    {
"Tactical (M4)",       2,  2,    3, 24, 31,  0,  0,  0,  0,  0, 0, 0, 0, 0, 0},
    {
"Tactical (Shotgun)",  2,    2,  3, 24, 27,  0,  0,  0,  0,  0, 0, 0, 0, 0, 0},
    {
"Tactical (Sniper)",   2,    2,  3, 24, 34,  0,  0,  0,  0,  0, 0, 0, 0, 0, 0},
    {
"Full Tactical",       2,    5,  3, 24, 25, 27, 29, 31, 34,  0, 0, 0, 0, 0, 0},
    
// GOVERNMENT
    
{"Bodyguard",             3,  1,    24, 29, 0,  0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
    {
"Mayor",                 3,  2,    24, 0,  0,  0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
};
///////////////////
showEquipMenu(playerid) {
    new 
temptxt[256];
    
dialogstr[0] = 0;
    new 
faction = GetPVarInt(playerid, "Faction");
    new 
rank = GetPVarInt(playerid, "Rank");
    for(new 
i=0;i<sizeof(EquipSlots);i++) {
        if(
faction == EquipSlots[i][EEquipFaction]) {
            if(
EquipSlots[i][ESWATENABLE] == 1) {
                if(
rank >= EquipSlots[i][EEquipMinRank]) {
                    
format(temptxt, sizeof(temptxt), "%s\n",EquipSlots[i][EEquipName]);
                    
strcat(dialogstr,temptxt,sizeof(dialogstr));
                }
            } else {
                if(
EquipSlots[i][ESWATENABLE] == 0) {
                    if(
rank == EquipSlots[i][EEquipMinRank]) {
                        
format(temptxt, sizeof(temptxt), "%s\n",EquipSlots[i][EEquipName]);
                        
strcat(dialogstr,temptxt,sizeof(dialogstr));
                    }
                }
            }            
        }
    }
    
ShowPlayerDialog(playerid, EFactionDialog_EquipChoose, DIALOG_STYLE_LIST, "{00BFFF}Equip Menu",dialogstr, "Ok", "Cancel");
}
////
case EFactionDialog_EquipChoose: {
            if(
response) {
                
onEquipResponse(playerid, listitem);
            }
        }
//onEquipResponse(playerid, index) {
    
new slot = getEquipListedAt(playerid, index);
    new 
msg[128];
    if(
GetPVarType(playerid, "CopDuty") == PLAYER_VARTYPE_NONE) {
        return 
1;
    }
    
ResetPlayerWeaponsEx(playerid);
    if(
EquipSlots[slot][EEquipGun1] != 0) {
        
GivePlayerWeaponEx(playerid, EquipSlots[slot][EEquipGun1], 100);
    }
    if(
EquipSlots[slot][EEquipGun2] != 0) {
        
GivePlayerWeaponEx(playerid, EquipSlots[slot][EEquipGun2], 100);
    }
    if(
EquipSlots[slot][EEquipGun3] != 0) {
        
GivePlayerWeaponEx(playerid, EquipSlots[slot][EEquipGun3], 500);
    }
    if(
EquipSlots[slot][EEquipGun4] != 0) {
        
GivePlayerWeaponEx(playerid, EquipSlots[slot][EEquipGun4], 500);
    }
    if(
EquipSlots[slot][EEquipGun5] != 0) {
        
GivePlayerWeaponEx(playerid, EquipSlots[slot][EEquipGun5], 500);
    }
    if(
EquipSlots[slot][EEquipGun6] != 0) {
        
GivePlayerWeaponEx(playerid, EquipSlots[slot][EEquipGun6], 100);
    }
    if(
EquipSlots[slot][EEquipGun7] != 0) {
        
GivePlayerWeaponEx(playerid, EquipSlots[slot][EEquipGun7], 100);
    }
    if(
EquipSlots[slot][EEquipGun8] != 0) {
        
GivePlayerWeaponEx(playerid, EquipSlots[slot][EEquipGun8], 100);
    }
    if(
EquipSlots[slot][EEquipGun9] != 0) {
        
GivePlayerWeaponEx(playerid, EquipSlots[slot][EEquipGun9], 100);
    }
    if(
EquipSlots[slot][EEquipGun10] != 0) {
        
GivePlayerWeaponEx(playerid, EquipSlots[slot][EEquipGun10], 100);
    }
    if(
EquipSlots[slot][EEquipGun11] != 0) {
        
GivePlayerWeaponEx(playerid, EquipSlots[slot][EEquipGun11], 100);
    }
    if(
EquipSlots[slot][EEquipGun12] != 0) {
        
GivePlayerWeaponEx(playerid, EquipSlots[slot][EEquipGun12], 100);
    }
    
SetPlayerHealthEx(playerid, 100.0);
    
SetPlayerArmourEx(playerid, 100.0);
    
format(msg, sizeof(msg), "* %s has suited %sself up with %s equipment.",GetPlayerNameEx(playerid, ENameType_RPName), getThirdPersonPersonalPronoun(playerid),EquipSlots[slot][EEquipName]);
    
ProxMessage(30.0, playerid, msg, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
    return 
0;
} 


The issue is as followed

I've assigned each slot it's own rank.
If that person == rank 1, They see rank 1 stuff...
But anyone over rank 1 doesn't get given the correct equipment..
They all get equipment of rank 1...
Can anyone see the issue..

Cause I really can't see where the hell i've gone an fuxed up.

If I make them ALL visable... It works fine..
but I want it so

Player X With Rank X
Can only see the stuff they're meant to see / equip the stuff they're meant to equip...

At the bottom I have "SWAT"...
That requires "SWAT_ENABLED (A Global Var) to be 1...)
But when that's 1... It shows up in the list "LIKE THE REST OF THE RANKED STUFF"...
BUT

When I equip it...
It gives me RANK 1 equipment..

Can anyone help me?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)