ricop522

[PAWN] Sistema de Gangs em MySQL

Mar 18th, 2012
283
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. new Query[200];
  2. const MAX_GANGS = 15;
  3. new Gangs;
  4.  
  5. enum gangInfo_ {
  6.     gID,
  7.     gNome[128],
  8.     gLider[24],
  9.     gSpawnX,
  10.     gSpawnY,
  11.     gSpawnZ,
  12.     gMatou,
  13.     gMorreu
  14. }
  15. new gangData[MAX_GANGS][gangInfo_];
  16.  
  17. stock vizualizarGangues(playerid) {
  18.     new i = 0;
  19.     while ( i <= MAX_GANGS ) {
  20.         format(Query, 200, "Nome: %s, Líder: %s\n%s", gangData[i][gNome], gangData[i][gLider], Query);
  21.         ShowPlayerDialog(playerid, 324, DIALOG_STYLE_LIST, "Gangs", Query, "OK", " ");
  22.     }
  23.     return 1;
  24. }
  25.  
  26.  
  27. stock adicionarGangue( nome[], lider[]) {
  28.     format ( Query, 200, "INSERT INTO `gangues` (`nome`, `lider`) VALUES ('%s', '%s')");
  29.     mysql_query( Query );
  30.     new
  31.         ID = mysql_insert_id();
  32.     gangData[ID][gID] = mysql_insert_id();
  33.     return 1;
  34. }
  35.  
  36. stock loadGangues() {
  37.     format( Query, 200, "SELECT * FROM `gangues`");
  38.     mysql_query( Query );
  39.     new gangID = 0;
  40.     while(mysql_retrieve_row()) {
  41.         Gangs++;
  42.         gangID++;
  43.         mysql_fetch_field_row(Query, "nome");
  44.         strmid(gangData[gangID][gNome], Query, 0, strlen(Query), 255);
  45.         mysql_fetch_field_row(Query, "lider");
  46.         strmid(gangData[gangID][gLider], string, 0, strlen(string), 255);
  47.     }
  48. }
RAW Paste Data