Mobile system
#10

use a constant / define for your max contacts
pawn Код:
#define MAX_CONTACTS (15)

enum mInfo
{
     ContactNumber[MAX_CONTACTS], // I have now 15 variables
     ContactName[30][MAX_CONTACTS], // I have now 15 string variables
};
new Mobiles[50][mInfo];
than create a stock for your dialog
pawn Код:
stock ShowPlayerContactDialog(playerid) { // I expect that szHugeString is a global variable
    for(new i = (szHugeString[0] = EOS); i != MAX_CONTACTS; i++) {
        if(Mobile[PlayerInfo[playerid][pPhoneID]][ContactNumber][i] != 0) {
            format(szHugeString, sizeof(szHugeString), "%s%i - %s\n", szHugeString, Mobile[PlayerInfo[playerid][pPhoneID]][ContactNumber][i], Mobile[PlayerInfo[playerid][pPhoneID][ContactName][i]);
        }
    }
    if(szHugeString[0] == EOS) {
        szHugeString = "No contacts!";
    }
    return ShowPlayerDialog(playerid, 9889, DIALOG_STYLE_LIST, "Contacts", szHugeString, "OK", "Delete");
}
and for the deletion part, you only need to move the others one place down
pawn Код:
//
    if(dialogid == 9889) {
        if(response) return 1;

        while(++listitem < MAX_CONTACTS) {
            Mobiles[PlayerInfo[playerid][pPhoneID][ContactNumber][listitem - 1] = Mobiles[PlayerInfo[playerid][pPhoneID][ContactNumber][listitem];
            Mobiles[PlayerInfo[playerid][pPhoneID][ContactName][listitem - 1] = Mobiles[PlayerInfo[playerid][pPhoneID][ContactName][listitem];
        }
        Mobiles[PlayerInfo[playerid][pPhoneID][ContactNumber][MAX_CONTACTS - 1] = 0;
        Mobiles[PlayerInfo[playerid][pPhoneID][ContactName][MAX_CONTACTS - 1] = "None";

        ShowPlayerContactDialog(playerid);
    }
}
Reply


Messages In This Thread
Mobile system - by Larry123 - 10.11.2012, 15:35
Re: Mobile system - by Virus. - 10.11.2012, 15:53
Re: Mobile system - by Konstantinos - 10.11.2012, 15:57
Re: Mobile system - by Larry123 - 10.11.2012, 16:04
Re: Mobile system - by Konstantinos - 10.11.2012, 16:16
Re: Mobile system - by Larry123 - 10.11.2012, 16:29
Re: Mobile system - by Konstantinos - 10.11.2012, 16:39
Re: Mobile system - by Larry123 - 10.11.2012, 16:44
Re: Mobile system - by Larry123 - 10.11.2012, 17:06
AW: Mobile system - by Nero_3D - 10.11.2012, 18:09

Forum Jump:


Users browsing this thread: 1 Guest(s)