Hello, I’m also encountering an issue with the /votemayor command.
After the mayor casts their vote, the `VoteMayor[id][jVote]` variable is not updated in the `/votelist` menu.
The /votelist menu (votes—VoteMayor[j][jVotes]—do not load here, but they do load in the database):
stock VoteMayorGetPlayerID(playerName[]) {
foreach(Player, i) {
if(IsPlayerConnected(i) && IsPlayerLogged[i] == 1) {
if(strcmp(VoteMayor[i][jName], playerName, true) == 0) return i;
}
}
return INVALID_PLAYER_ID;
}
CMD:votelist(playerid, params[]) {
new szDialog[1024], szDialog2[1024], szTitle[50], xx;
strcat(szDialog2, "Candidates\tVotes\n");
for(new j = 0; j < MAX_PLAYERS; j++) {
if(strlen(VoteMayor[j][jName]) >= 1) {
format(szDialog, sizeof(szDialog), "%s\t%d\n", VoteMayor[j][jName], VoteMayor[j][jVotes]);
strcat(szDialog2, szDialog);
xx++;
}
}
format(szTitle, sizeof(szTitle), "Candidates: %d", xx);
ShowPlayerDialog(playerid, 0, DIALOG_STYLE_TABLIST_HEADERS, szTitle, szDialog2, "Cancel", "");
return 1;
}
case DIALOG_VOTE_MAYOR: {
if(!response) return 1;
new name[32];
GetPVarString(playerid, "playerName", name, sizeof(name));
new userID = VoteMayorGetPlayerID(name);
if(userID != INVALID_PLAYER_ID) {
VoteMayor[userID][jVotes] += 1;
format(string, sizeof(string), "%s te-a votat ca primar.", GetName(playerid));
SCM(userID, -1, string);
}
format(string, sizeof(string), "UPDATE `votemayor` SET `Votes`=`Votes`+1 WHERE `Name`='%s'", name);
mysql_tquery(SQL,string, "", "");
format(string, sizeof(string), "L-ai votat pe %s ca primar al comunitatii.", name);
SCM(playerid, COLOR_LGREEN, string);
}
After the mayor casts their vote, the `VoteMayor[id][jVote]` variable is not updated in the `/votelist` menu.
The /votelist menu (votes—VoteMayor[j][jVotes]—do not load here, but they do load in the database):
stock VoteMayorGetPlayerID(playerName[]) {
foreach(Player, i) {
if(IsPlayerConnected(i) && IsPlayerLogged[i] == 1) {
if(strcmp(VoteMayor[i][jName], playerName, true) == 0) return i;
}
}
return INVALID_PLAYER_ID;
}
CMD:votelist(playerid, params[]) {
new szDialog[1024], szDialog2[1024], szTitle[50], xx;
strcat(szDialog2, "Candidates\tVotes\n");
for(new j = 0; j < MAX_PLAYERS; j++) {
if(strlen(VoteMayor[j][jName]) >= 1) {
format(szDialog, sizeof(szDialog), "%s\t%d\n", VoteMayor[j][jName], VoteMayor[j][jVotes]);
strcat(szDialog2, szDialog);
xx++;
}
}
format(szTitle, sizeof(szTitle), "Candidates: %d", xx);
ShowPlayerDialog(playerid, 0, DIALOG_STYLE_TABLIST_HEADERS, szTitle, szDialog2, "Cancel", "");
return 1;
}
case DIALOG_VOTE_MAYOR: {
if(!response) return 1;
new name[32];
GetPVarString(playerid, "playerName", name, sizeof(name));
new userID = VoteMayorGetPlayerID(name);
if(userID != INVALID_PLAYER_ID) {
VoteMayor[userID][jVotes] += 1;
format(string, sizeof(string), "%s te-a votat ca primar.", GetName(playerid));
SCM(userID, -1, string);
}
format(string, sizeof(string), "UPDATE `votemayor` SET `Votes`=`Votes`+1 WHERE `Name`='%s'", name);
mysql_tquery(SQL,string, "", "");
format(string, sizeof(string), "L-ai votat pe %s ca primar al comunitatii.", name);
SCM(playerid, COLOR_LGREEN, string);
}
