Advertisement
Guest User

Untitled

a guest
Sep 4th, 2015
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.58 KB | None | 0 0
  1. // Tworzenie tabeli w bazie danych z pracownikami
  2.  
  3. s_buf="CREATE TABLE IF NOT EXISTS `pracownicy`(";
  4.     strcat(s_buf, "puid INT NOT NULL,"); // zapisuje UID gracza
  5.     strcat(s_buf, "pname VARCHAR(24) NOT NULL,"); // zapisuje nick gracza
  6.     strcat(s_buf, "zarobek INT NOT NULL,"); // zapisuje zarobione pieniądze w danej grupie
  7.     strcat(s_buf, "wydatek INT NOT NULL,"); // zapisuje wydane pieniądze w danej grupie
  8.     strcat(s_buf, "score INT NOT NULL,"); // zapisuje zdobyte score w danej grupie
  9.     strcat(s_buf, "teamid INT NOT NULL)"); // zapisuje UID teamu do jakiego gracz należy
  10.     mysql_query(s_buf);
  11. }
  12.  
  13.  
  14. #define MAX_PRAC 10
  15. enum ePracownik
  16. {
  17.     pUID,
  18.     pname[24],
  19.     zarobek,
  20.     wydatek,
  21.     score,
  22.     teamid
  23. }
  24. new praco[MAX_PLAYERS][MAX_PRAC][ePracownik];
  25.  
  26. stock IsPlayerInUidGroup(playerid, groupuid)
  27. {
  28.     for(new groupid; groupid != MAX_PRAC; groupid++)
  29.     {
  30.         if(praco[playerid][groupid][teamid] == groupuid)
  31.             return groupid;
  32.     }
  33.     return false;
  34. }
  35.  
  36. forward LoadPraco(playerid);
  37. public LoadPraco(playerid)
  38. {
  39.     new query[256], slotid;
  40.     format(query, sizeof(query), "SELECT zarobek, wydatek, score, teamid FROM `pracownicy` WHERE `puid` = '%d'", PlayerData[playerid][pUID]);
  41.     mysql_query(query);
  42.    
  43.     mysql_store_result();
  44.     while(mysql_fetch_row(query, "|"))
  45.     {
  46.         slotid++;
  47.         sscanf(query, "p<|>dddd",
  48.         praco[playerid][slotid][zarobek],
  49.         praco[playerid][slotid][wydatek],
  50.         praco[playerid][slotid][score],
  51.         praco[playerid][slotid][teamid]);
  52.     }
  53.     mysql_free_result();
  54.     return 1;
  55. }
  56.  
  57. CMD:praca(playerid, params[])
  58. {
  59.     new string[128], slotid;
  60.     format(string, sizeof(string), "Pracujesz w %d", praco[playerid][slotid][teamid]);
  61.     SendClientMessage(playerid, -1, string);
  62.     return 1;
  63. }
  64.    
  65.  
  66.  
  67.  
  68. CMD:g(playerid, params[])
  69. {
  70.     new string1[64], string2[64];
  71.     new grupa = IsPlayerInUidGroup(playerid, praco[playerid][grupa][teamid]);
  72.     if(sscanf(params, "ds[64]S()[64]", grupa, string1, string2))
  73.         return SendClientMessage(playerid, -1, "Błąd");
  74.        
  75.     if(!strcmp(string1, "score", true))
  76.     {
  77.         if(!praco[playerid][grupa][teamid]) return 1;
  78.        
  79.         new query[128];
  80.         format(query, sizeof(query), "UPDATE `pracownicy` SET score = '%d' WHERE teamid = '%d' LIMIT 1", 10, praco[playerid][grupa][teamid]);
  81.         mysql_query(query);
  82.         return 1;
  83.     }
  84.        
  85.     /*if(!praco[playerid][grupa][teamid])
  86.     {
  87.         SendClientMessage(playerid, -1, "Nie pracujesz w tym teamie");
  88.         return 1;
  89.     }
  90.     else
  91.     {
  92.         format(string, sizeof(string), "Zalogowałeś się na grupę, UID: %d", praco[playerid][grupa][teamid]);
  93.         SendClientMessage(playerid, -1, string);
  94.         return 1;
  95.     }*/
  96.     return 1;
  97. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement