Jump to content

Question

Posted (edited)

Dupa ce voteaza primarul nu aduna variabila VoteMayor[id][jVote] din meniul /votelist

 

Cand Voteaza:

Quote

        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);
        }

Meniul /votelist (aici nu incarca voturile (VoteMayor[j][jVotes]) dar in baza de date incarca):

Quote

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;
}

Edited by pawnoOo

1 answer to this question

Recommended Posts

  • 0
Posted

functia VoteMayorGetPlayerID

Quote

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;
}

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   1 member

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.