Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Tworzenie tabeli w bazie danych z pracownikami
- s_buf="CREATE TABLE IF NOT EXISTS `pracownicy`(";
- strcat(s_buf, "puid INT NOT NULL,"); // zapisuje UID gracza
- strcat(s_buf, "pname VARCHAR(24) NOT NULL,"); // zapisuje nick gracza
- strcat(s_buf, "zarobek INT NOT NULL,"); // zapisuje zarobione pieniądze w danej grupie
- strcat(s_buf, "wydatek INT NOT NULL,"); // zapisuje wydane pieniądze w danej grupie
- strcat(s_buf, "score INT NOT NULL,"); // zapisuje zdobyte score w danej grupie
- strcat(s_buf, "teamid INT NOT NULL)"); // zapisuje UID teamu do jakiego gracz należy
- mysql_query(s_buf);
- }
- #define MAX_PRAC 10
- enum ePracownik
- {
- pUID,
- pname[24],
- zarobek,
- wydatek,
- score,
- teamid
- }
- new praco[MAX_PLAYERS][MAX_PRAC][ePracownik];
- stock IsPlayerInUidGroup(playerid, groupuid)
- {
- for(new groupid; groupid != MAX_PRAC; groupid++)
- {
- if(praco[playerid][groupid][teamid] == groupuid)
- return groupid;
- }
- return false;
- }
- forward LoadPraco(playerid);
- public LoadPraco(playerid)
- {
- new query[256], slotid;
- format(query, sizeof(query), "SELECT zarobek, wydatek, score, teamid FROM `pracownicy` WHERE `puid` = '%d'", PlayerData[playerid][pUID]);
- mysql_query(query);
- mysql_store_result();
- while(mysql_fetch_row(query, "|"))
- {
- slotid++;
- sscanf(query, "p<|>dddd",
- praco[playerid][slotid][zarobek],
- praco[playerid][slotid][wydatek],
- praco[playerid][slotid][score],
- praco[playerid][slotid][teamid]);
- }
- mysql_free_result();
- return 1;
- }
- CMD:praca(playerid, params[])
- {
- new string[128], slotid;
- format(string, sizeof(string), "Pracujesz w %d", praco[playerid][slotid][teamid]);
- SendClientMessage(playerid, -1, string);
- return 1;
- }
- CMD:g(playerid, params[])
- {
- new string1[64], string2[64];
- new grupa = IsPlayerInUidGroup(playerid, praco[playerid][grupa][teamid]);
- if(sscanf(params, "ds[64]S()[64]", grupa, string1, string2))
- return SendClientMessage(playerid, -1, "Błąd");
- if(!strcmp(string1, "score", true))
- {
- if(!praco[playerid][grupa][teamid]) return 1;
- new query[128];
- format(query, sizeof(query), "UPDATE `pracownicy` SET score = '%d' WHERE teamid = '%d' LIMIT 1", 10, praco[playerid][grupa][teamid]);
- mysql_query(query);
- return 1;
- }
- /*if(!praco[playerid][grupa][teamid])
- {
- SendClientMessage(playerid, -1, "Nie pracujesz w tym teamie");
- return 1;
- }
- else
- {
- format(string, sizeof(string), "Zalogowałeś się na grupę, UID: %d", praco[playerid][grupa][teamid]);
- SendClientMessage(playerid, -1, string);
- return 1;
- }*/
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement