Jump to content

Recommended Posts

Posted (edited)

Salut !

Am nevoie de un sistem de editare a jucatorului atunci cand este offline.

De exemplu: /mcontrol [numele jucatorului] iar dupa sa imi apara un dialog cu lucrurile pe care ii le pot modifica, de exemplu: Admin-ul, Coins, Gems, etc.

Edited by m0untain
  • 4 years later...
Posted

1. Primadata trebuie sa pui plugin-ul mysql in server.cfg

Windows: plugins mysql

Sau

Linux: plugins mysql.so

(cred ca ai deja pus, dar am pus de siguranta).

2. Comanda:

Pentru strcmp (adica in OnplayerCommandText): new cmd[256], arg[256];

 

 new cmd[256], arg[256]; 

 if (sscanf(cmdtext, "s[256]S()[256]", cmd, arg)) return 0;

 

 else if (strcmp(cmd, "/mcontrol", true) == 0)

 {

  ShowPlayerDialog(playerid, DIALOG_EDIT_PLAYER, DIALOG_STYLE_LIST, "Player Edit", "Admin\nCoins\nGems", "Edit", "Cancel");

  return 1;

 }

 

Pt celelalte (ZCMD, etc): 

CMD:mcontrol(playerid, params[]) {

ShowPlayerDialog(playerid, DIALOG_EDIT_PLAYER, DIALOG_STYLE_LIST, "Player Edit", "Admin\nCoins\nGems", "Edit", "Cancel");

return 1;}

3. OnDialogResponse

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])

{

 if (dialogid == DIALOG_EDIT_PLAYER)

 {

  if (response)

  {

   new playerToEdit[MAX_PLAYER_NAME];

            format(playerToEdit, sizeof(playerToEdit), "%s", inputtext);

            switch (listitem)

            {

    case 0: // Admin

     new query[256];

                    format(query, sizeof(query), "UPDATE players SET admin = 1 WHERE name = '%s'", playerToEdit);

                    mysql_query(query);

                    break;

    case 1: // Coins

                    format(query, sizeof(query), "UPDATE players SET coins = 100 WHERE name = '%s'", playerToEdit);

                    mysql_query(query);

                    break;

    case 2: // Gems

                    format(query, sizeof(query), "UPDATE players SET gems = 100 WHERE name = '%s'", playerToEdit);

                    mysql_query(query);

                    break;

   }

  }

 }

 

Cam atat, dupa gems poti sa mai creezi tu dupa același model, eu nu am făcut mai multe pentru că nu știu ce mai ai tu în baza de date a gamemode-ului tău.

Sper că te-am ajutat, spor.

(probabil nu te-am ajutat ca esti inactiv pe forum =)), dar poate am ajutat pe altcnv).

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
×
×
  • 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.