Advertisement
Guest User

Untitled

a guest
Apr 21st, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. #include amxmodx
  2. #include sqlx
  3.  
  4. new Handle:g_SqlTuple;
  5. new hasLicense;
  6. new g_Error[512];
  7.  
  8. public plugin_init()
  9. {
  10. register_plugin("CSGO License", "1.0", "SideWinder");
  11. return 0;
  12. }
  13.  
  14. public plugin_precache()
  15. {
  16. MySql_Init();
  17. return 0;
  18. }
  19.  
  20. public plugin_natives()
  21. {
  22. register_native("e6117f86f7fcfc7465552067c8491139", "native_e6117f86f7fcfc7465552067c8491139", 1);
  23. return 0;
  24. }
  25.  
  26. public MySql_Init()
  27. {
  28. g_SqlTuple = SQL_MakeDbTuple("tot plm", "plm", "parola", "plm", 0);
  29. new ErrorCode = 0;
  30. new Handle:SqlConnection = SQL_Connect(g_SqlTuple, ErrorCode, g_Error, 511);
  31. if (!SqlConnection)
  32. {
  33. set_fail_state(g_Error);
  34. }
  35. SQL_FreeHandle(SqlConnection);
  36. Load_MySql();
  37. return 0;
  38. }
  39.  
  40. public plugin_end()
  41. {
  42. SQL_FreeHandle(g_SqlTuple);
  43. return 0;
  44. }
  45.  
  46. public Load_MySql()
  47. {
  48. new szTemp[512];
  49. new Data[1];
  50. format(szTemp, 511, "SELECT * FROM `csgo_license` WHERE (`server_ip` = '%s')", "89.39.14.83");
  51. SQL_ThreadQuery(g_SqlTuple, "register_client", szTemp, Data, 1);
  52. return 0;
  53. }
  54.  
  55. public register_client(FailState, Handle:Query, Error[], Errcode, Data[], DataSize)
  56. {
  57. if (FailState == -2)
  58. {
  59. log_amx("Load - Could not connect to SQL database. [%d] %s", Errcode, Error);
  60. }
  61. else
  62. {
  63. if (FailState == -1)
  64. {
  65. log_amx("Load Query failed. [%d] %s", Errcode, Error);
  66. }
  67. }
  68. if (1 > SQL_NumResults(Query))
  69. {
  70. hasLicense = 0;
  71. }
  72. else
  73. {
  74. hasLicense = 1;
  75. }
  76. return 1;
  77. }
  78.  
  79. public IgnoreHandle(FailState, Handle:Query, String:Error[], Errcode, String:Data[], DataSize)
  80. {
  81. SQL_FreeHandle(Query);
  82. return 1;
  83. }
  84.  
  85. public native_e6117f86f7fcfc7465552067c8491139()
  86. {
  87. return hasLicense;
  88. }
  89.  
  90. public deb(id)
  91. {
  92. client_print(id, print_chat, "%s %d", "89.39.14.83", hasLicense);
  93. return 0;
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement