Stuneris

AccBan [MySQL]

Jul 25th, 2011
423
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.86 KB | None | 0 0
  1. #include <a_samp>
  2. #include <zcmd>
  3. #include <sscanf>
  4. #include <a_mysql>
  5.  
  6. #define SQL_HOST            "localhost"
  7. #define SQL_USER            "root"
  8. #define SQL_PASS            ""
  9. #define SQL_DB              "DB_NAME"
  10. #define BANS_TABLE                  "banai"
  11.  
  12. public OnPlayerSpawn(playerid)
  13. {
  14.     new query[140];
  15.     format(query, 140, "SELECT 'Blocked' FROM "BANS_TABLE" WHERE 'Name' = '%s'", PlayerName(playerid));
  16.     mysql_query(query);
  17.     mysql_store_result();
  18.     if(mysql_num_rows() != 0)
  19.     {
  20.             SendClientMessage(playerid, 0xFF0000FF, "Šis account'as užblokuotas");
  21.             Kick(playerid);
  22.     }
  23.     return 1;
  24. }
  25.  
  26. CMD:accban(playerid, params[])
  27. {
  28.         new zID, Reason[128];
  29.     if(sscanf(params,"is", zID, Reason)) return SendClientMessage(playerid, -1, "{FF0000}Užblokuoti žaidėjo acc: /ban [žaidėjo ID] [Priežastis]");
  30.     if(zID == INVALID_PLAYER_ID && !IsPlayerNPC(zID)) return SendClientMessage(playerid, -1, "{FF0000} Žaidėjo su šiuo ID serveryje nėra.");
  31.     if(zID == playerid) return SendClientMessage(playerid, -1, "{FF0000}Savo acc užblokuoti negalite.");
  32.     new string[128];
  33.     format(string, 128, "Administratorius %s užblokavo %s account'ą(priežastis: %s)", PlayerName(playerid), PlayerName(zID), Reason);
  34.     SendClientMessageToAll(0xFF0000FF, string);
  35.     format(string, 128, "Administratorius %s užblokavo jūsų account'ą(priežastis: %s)", PlayerName(playerid), Reason);
  36.     SendClientMessage(zID, 0xFF0000FF, string);
  37.     BanAcc(zID, PlayerName(playerid), Reason);
  38.     Kick(zID);
  39.     return 1;
  40. }
  41.  
  42. BanAcc(playerid, adminid[], reason[])
  43. {
  44.     new query[256], year, month, day;
  45.     getdate(year, month, day);
  46.     format(query, 256, "INSERT INTO "BANS_TABLE" (Name, Blocked, Reason) VALUES ('%s', '%s', '%s')", PlayerName(playerid), adminid, reason);
  47.     mysql_query(query);
  48.     mysql_free_result();
  49. }
  50.  
  51. PlayerName(id)
  52. {
  53.     new name[MAX_PLAYER_NAME];
  54.     GetPlayerName(id, name, MAX_PLAYER_NAME);
  55.     return name;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment