Advertisement
Aninhaah

Comando /daradmin e salvamento

Jul 6th, 2012
371
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.87 KB | None | 0 0
  1. #include <a_samp>
  2. #include <DOF2>
  3. #include <zcmd>
  4. #include <sscanf>
  5.  
  6. enum pInfo
  7. {
  8.     pAdmin
  9. };
  10. new PlayerInfo[MAX_PLAYERS][pInfo];
  11.  
  12.  
  13. CMD:daradmin(playerid, params[])
  14. {
  15.     if(IsPlayerAdmin(playerid) || PlayerInfo[playerid][pInfo] >= 20) //verifica se ele é adm na rcon ou se ele é adm maior ou igual 20
  16.     {
  17.         new gp, nvl; //gp = giveplayerid (pessoa que vai receber o adm), nvl = nivel (nivel que admin vai dar)
  18.         if(sscanf(params,"ud", giveplayerid, nvl)) return SendClientMessage(playerid,-1,"Use: /daradmin [ID] [Nivel]");
  19.         //o u em "ud" é para players, porque dai pode usar /daradmin [nome] [nivel] ou /daradmin [id] [nivel]
  20.         // d é para numeros e s é para texto, dps que por o "ud"  tem que por a variavel em qe kd um corresponde (na ordem)
  21.         PlayerInfo[giveplayerid][pAdmin] = nvl; //seta admin pro giveplayerid (player qe ganhou) com o nivel q o adm digitou
  22.         new str[120], nomeg[MAX_PLAYER_NAME], nomep[MAX_PLAYER_NAME];
  23.         GetPlayerName(playerid, nomep, sizeof(nomep));
  24.         GetPlayerName(giveplayerid, nomeg, sizeof(nomeg));
  25.         format(str, sizeof(str),"%s deu admin nivel %d para %s.", nomep, nvl, nomeg);
  26.         SendClientMessage(playerid,-1, string);
  27.         if(playerid != giveplayerid) { SendClientMessage(giveplayerid,-1, string); } // aqui, so vai manda a msg caso a pessoa nao esteja dando adm pra ela mesma, se nao vai manda  a mesma msg 2 vezes
  28.         SalvarConta(giveplayerid);//vai chaamar a stock q vai salvar o giveplayerid
  29.     }
  30.     else return SendClientMessage(playerid,-1,"Voce nao pode usar o cmd"); // vai manda msg pro player caso nao seja admin
  31.     return 1;
  32. }
  33.  
  34.  
  35. stock SalvarConta(playerid)
  36. {
  37.     new nome[MAX_PLAYER_NAME], file[56];
  38.     GetPlayerName(playerid, nome, sizeof(nome));
  39.     format(file, sizeof(file),"Contas/%s.ini", nome);
  40.     if(DOF2_FileExists(file))
  41.     {
  42.         DOF2_SetInt(file,"Nivel Adm", PlayerInfo[playerid][pAdmin]);
  43.         DOF2_SaveFile();
  44.     }
  45.     return 1;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement