Advertisement
Guest User

Untitled

a guest
Aug 28th, 2016
311
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. BASE ADMIN = abcdfjgk
  3. BASE VIP = o
  4. 0 AA/VIP = BASE ADMIN / BASE VIP
  5. 1 GAA = BASE ADMIN + CUSTOM6
  6. 2 GAS = BASE ADMIN + CUSTOM6
  7. 3 GSS = BASE ADMIN + UNBAN + CUSTOM6
  8. 4 RSP = BASE ADMIN + UNBAN + CUSTOM6
  9.  
  10. */
  11.  
  12. #pragma semicolon 1
  13.  
  14. #define PLUGIN_AUTHOR "Kupah"
  15. #define PLUGIN_VERSION "1.00"
  16.  
  17. #include <sourcemod>
  18. #include <sdktools>
  19. #include <morecolors>
  20.  
  21. #pragma newdecls required
  22.  
  23. Database connection;
  24. ConVar cvar_url;
  25.  
  26. int sid = 1; // ID DU GAME
  27. int id[MAXPLAYERS + 1] = -1;
  28. int lvl[MAXPLAYERS + 1] = -1;
  29. int imu[MAXPLAYERS + 1] = -1;
  30.  
  31. bool vip[MAXPLAYERS + 1] = false;
  32. bool admin[MAXPLAYERS + 1] = false;
  33.  
  34. public Plugin myinfo =  {
  35.     name = "",
  36.     author = PLUGIN_AUTHOR,
  37.     description = "",
  38.     version = PLUGIN_VERSION,
  39.     url = "recrutement.crazybro.net"
  40. };
  41.  
  42. public void OnPluginStart() {
  43.     cvar_url = CreateConVar("website_url", "http://recrutement.crazybro.net/", "Website url");
  44.     AutoExecConfig(true, "boutique");
  45.    
  46.     RegConsoleCmd("sm_vip", Command_VIP);
  47.     RegConsoleCmd("sm_autoadmin", Command_VIP);
  48.     RegConsoleCmd("sm_check", cmd_droits);
  49. }
  50.  
  51. public void OnClientPostAdminCheck(int client) {
  52.     CreateTimer(1.0, Refresh, client);
  53. }
  54.  
  55. public int OnRebuildAdminCache(AdminCachePart part) {
  56.     if (part == AdminCache_Admins) {
  57.         for (int i = 1; i <= MaxClients; i++)
  58.         CreateTimer(1.0, Refresh, i);
  59.     }
  60. }
  61.  
  62. public Action Refresh(Handle timer, int client) {
  63.     if (!client || !IsClientInGame(client) || IsFakeClient(client))
  64.         return;
  65.     refresh(client);
  66. }
  67.  
  68. void refresh(int client) {
  69.     char sql[364];
  70.     char steamid[64];
  71.     GetClientAuthId(client, AuthId_Steam2, steamid, sizeof(steamid));
  72.    
  73.     admin[client] = false;
  74.     vip[client] = false;
  75.     RemoveUserFlags(client, Admin_Custom1, Admin_Reservation, Admin_Generic, Admin_Kick, Admin_Ban, Admin_Slay, Admin_Chat, Admin_Custom6, Admin_Unban, Admin_Changemap, Admin_Vote);
  76.    
  77.     Format(sql, sizeof(sql), "SELECT id, level FROM rct_users WHERE steamid = '%s'", steamid);
  78.     connection.Query(CallbackClientID, sql, client);
  79. }
  80.  
  81. public void CallbackClientID(Database db, DBResultSet result, char[] error, any client) {
  82.     if (result == null) {
  83.         LogError("[BDD] Erreur SQL(CLIENTID): %s", error);
  84.         return;
  85.     }
  86.     else if (result.RowCount <= 0)
  87.         return;
  88.    
  89.     char sql[364];
  90.    
  91.     result.FetchRow();
  92.     id[client] = result.FetchInt(0);
  93.     lvl[client] = result.FetchInt(1);
  94.    
  95.     if (lvl[client] == 0)
  96.         imu[client] = 1;
  97.     else if (lvl[client] == 1)
  98.         imu[client] = 10;
  99.     else if (lvl[client] == 2)
  100.         imu[client] = 20;
  101.     else if (lvl[client] == 3)
  102.         imu[client] = 30;
  103.     else if (lvl[client] == 4)
  104.         imu[client] = 40;
  105.     else if (lvl[client] == 5)
  106.         imu[client] = 100;
  107.    
  108.     Format(sql, sizeof(sql), "SELECT type, end FROM rct_droits WHERE id = '%i' AND game_id = '%i'", id[client], sid);
  109.     connection.Query(CallbackClientInfo, sql, client);
  110. }
  111.  
  112. public void CallbackClientInfo(Database db, DBResultSet result, char[] error, any client) {
  113.     if (result == null) {
  114.         LogError("[BDD] Erreur SQL(CLIENTINFO): %s", error);
  115.         return;
  116.     }
  117.     else if (result.RowCount <= 0) {
  118.         return;
  119.     }
  120.    
  121.     int type = -1;
  122.     int end = -1;
  123.     while (result.FetchRow()) {
  124.         type = result.FetchInt(0);
  125.         end = result.FetchInt(1);
  126.        
  127.         int timeleft = end - GetTime();
  128.         if (timeleft <= 0)
  129.             DeleteClient(client, type);
  130.         else {
  131.             if (type == 1)
  132.                 admin[client] = true;
  133.             else if (type == 0)
  134.                 vip[client] = true;
  135.         }
  136.     }
  137.     AddClient(client);
  138. }
  139.  
  140. public Action Command_VIP(int client, int args) {
  141.     QueryClientConVar(client, "cl_disablehtmlmotd", motd_access);
  142. }
  143.  
  144. public int Nothing(Handle menu, MenuAction action, int param1, int param2) {  }
  145.  
  146. public void motd_access(QueryCookie cookie, int client, ConVarQueryResult result, const char[] cvarName, const char[] cvarValue) {
  147.     char steamid[64];
  148.     char url[364];
  149.     char website[256];
  150.     char msg[1024];
  151.    
  152.     GetClientAuthId(client, AuthId_Steam2, steamid, sizeof(steamid));
  153.     cvar_url.GetString(website, sizeof(website));
  154.    
  155.     if (!StrEqual(cvarValue, "0")) {
  156.         Handle Paide = CreatePanel();
  157.         Format(msg, sizeof(msg), "________________\n   - AIDE -   \n¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯\nVous devez activer les MOTDs HTML, appuyez sur ECHAP\n \nOptions -> Onglet 'Multijoueurs' -> Appuyez sur le bouton 'Avancé...'\nDécochez ensuite 'Désactiver les MOTDs HTML.'\nCliquez sur OK.\n \n Vous pouvez maintenant retaper !vip\nSi vous ne souhaitez pas activer vos messages du jour, vous pouvez vous inscrire depuis le site %sindex.php \n0 - Fermer", website);
  158.         DrawPanelText(Paide, msg);
  159.         SetPanelCurrentKey(Paide, 10);
  160.         SendPanelToClient(Paide, client, Nothing, 30);
  161.     } else {
  162.         Format(url, sizeof(url), "%sindex.php?steamid=%s&name=%N", website, steamid, client);
  163.         ShowMOTDPanel(client, "CrazyBro", url, 2);
  164.     }
  165. }
  166.  
  167. void DeleteClient(int client, int type) {
  168.     char sql[364];
  169.     Format(sql, sizeof(sql), "DELETE FROM rct_droits WHERE id = '%i' AND game_id = '%i' AND type = '%i'", id[client], sid, type);
  170.     connection.Query(CallbackDroitsDelete, sql, client);
  171. }
  172.  
  173. public void CallbackDroitsDelete(Database db, DBResultSet result, char[] error, any client) {
  174.     if (result == null) {
  175.         LogError("[BDD] Erreur SQL(DELETE): %s", error);
  176.         return;
  177.     }
  178.     RemoveUserFlags(client, Admin_Custom1, Admin_Reservation, Admin_Generic, Admin_Kick, Admin_Ban, Admin_Slay, Admin_Chat, Admin_Custom6, Admin_Unban, Admin_Changemap, Admin_Vote);
  179. }
  180.  
  181. public void CallbackTotalUpdate(Database db, DBResultSet result, char[] error, any data) {
  182.     if (result == null) {
  183.         LogError("[BDD] Erreur SQL(UPDATE): %s", error);
  184.         return;
  185.     }
  186. }
  187.  
  188. void AddClient(int client) {
  189.     if (!client || !IsClientInGame(client) || IsFakeClient(client))
  190.         return;
  191.    
  192.     int Flags = GetUserFlagBits(client);
  193.     AdminId aid = GetUserAdmin(client);
  194.    
  195.     if (aid == INVALID_ADMIN_ID) {
  196.         aid = CreateAdmin();
  197.         SetUserAdmin(client, aid, true);
  198.     }
  199.    
  200.     if (vip[client])
  201.         Flags |= ADMFLAG_CUSTOM1;
  202.     if (admin[client]) {
  203.         Flags |= ADMFLAG_GENERIC | ADMFLAG_KICK | ADMFLAG_BAN | ADMFLAG_SLAY | ADMFLAG_CHAT | ADMFLAG_CHANGEMAP | ADMFLAG_VOTE;
  204.         if (lvl[client] >= 1)
  205.             Flags |= ADMFLAG_CUSTOM6 | ADMFLAG_RCON;
  206.         if (lvl[client] >= 3)
  207.             Flags |= ADMFLAG_RESERVATION | ADMFLAG_UNBAN;
  208.         if (lvl[client] == 5)
  209.             Flags |= ADMFLAG_ROOT;
  210.     }
  211.     SetUserFlagBits(client, Flags);
  212.     SetAdminImmunityLevel(aid, imu[client]);
  213. }
  214.  
  215. // DEV CMD
  216.  
  217. public Action cmd_droits(int client, int args) {
  218.     if (!client || !IsClientInGame(client) || IsFakeClient(client) || !(GetUserFlagBits(client) & ADMFLAG_ROOT))
  219.         return;
  220.    
  221.     int imun = GetAdminImmunityLevel(GetUserAdmin(client));
  222.    
  223.     PrintToChat(client, "GAME_ID : %i", sid);
  224.     PrintToChat(client, "USER_ID : %i", id[client]);
  225.     PrintToChat(client, "LEVEL : %i", lvl[client]);
  226.     PrintToChat(client, "IMUNITY : %i", imu[client]);
  227.     PrintToChat(client, "IMUN : %i", imun);
  228.     if (vip[client])
  229.         PrintToChat(client, "VIP");
  230.     if (admin[client]) {
  231.         PrintToChat(client, "AA");
  232.         if (lvl[client] >= 1)
  233.             PrintToChat(client, "GAA,GAS,GSS");
  234.         if (lvl[client] >= 3)
  235.             PrintToChat(client, "RSP,LEADER");
  236.         if (lvl[client] == 5)
  237.             PrintToChat(client, "FONDA");
  238.     }
  239. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement