Guest User

Untitled

a guest
Jul 29th, 2016
279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.35 KB | None | 0 0
  1. /*
  2. sclan.inc by Shinja
  3. All copyrights reserved
  4. Do not edit, even bugs
  5. Report to original developer
  6.  
  7. Requirements:
  8. MySQL R39-5 by BlueG
  9. http://forum.sa-mp.com/showthread.php?t=56564
  10.  
  11. */
  12.  
  13. #include <a_samp>
  14. #include <a_mysql>
  15.  
  16. native Shinja_CreateClan(name[], connectionHandle);
  17. native Shinja_DestroyClan(clanid, connectionHandle);
  18. native Shinja_IsClanExists(clanid, connectionHandle);
  19. native Shinja_IsClanNameExists(name[], connectionHandle);
  20. native Shinja_GetClanID(name[], connectionHandle);
  21. native Shinja_GetClanName(clanid, connectionHandle);
  22. native Shinja_GetPlayerClan(playerid, connectionHandle);
  23. native Shinja_SetPlayerClan(playerid, clanid, connectionHandle);
  24. native Shinja_IsPlayerInAnyClan(playerid, connectionHandle);
  25.  
  26. stock IsPlayerInAnyClan(playerid, connectionHandle)
  27. {
  28. new string[128];
  29. format(string, sizeof(string), "SELECT Clan FROM Users WHERE Name = '%s'", GetName(playerid));
  30. new Cache:resultt = mysql_query(connectionHandle, string);
  31. new value = cache_get_field_content_int(0, "Clan");
  32. cache_delete(resultt);
  33. if(value == -1) return false;
  34. else return true;
  35. }
  36.  
  37. stock CreateClan(name[], connectionHandle)
  38. {
  39. new string[128];
  40. format(string, sizeof(string), "INSERT INTO Clans (Name) VALUES ('%s')", name);
  41. mysql_query(connectionHandle, string);
  42. }
  43.  
  44. stock DestroyClan(clanid, connectionHandle)
  45. {
  46. new string[128];
  47. format(string, sizeof(string), "DELETE FROM Clans WHERE ID = '%d'", clanid);
  48. mysql_query(connectionHandle, string);
  49. }
  50.  
  51. stock IsClanExists(clanid, connectionHandle)
  52. {
  53. new string[128];
  54. format(string, sizeof(string), "SELECT * FROM Clans WHERE ID = '%d'", clanid);
  55. new Cache:resultt = mysql_query(connectionHandle, string);
  56. new value = cache_num_rows();
  57. cache_delete(resultt);
  58. return value;
  59. }
  60.  
  61. stock IsClanNameExists(name[], connectionHandle)
  62. {
  63. new string[128];
  64. format(string, sizeof(string), "SELECT * FROM Clans WHERE Name = '%s'", name);
  65. new Cache:resultt = mysql_query(connectionHandle, string);
  66. new value = cache_num_rows();
  67. cache_delete(resultt);
  68. return value;
  69. }
  70.  
  71. stock GetClanID(name[], connectionHandle)
  72. {
  73. new string[128];
  74. format(string, sizeof(string), "SELECT ID FROM Clans WHERE Name = '%s'", name);
  75. new Cache: resull = mysql_query(connectionHandle, string);
  76. new ID = cache_get_field_content_int(0, "ID");
  77. cache_delete(resull);
  78. return ID;
  79. }
  80.  
  81. stock GetClanName(clanid, connectionHandle)
  82. {
  83. new string[128];
  84. format(string, sizeof(string), "SELECT Name FROM Clans WHERE ID = '%d'", clanid);
  85. new Cache: res = mysql_query(string, connectionHandle);
  86. new Name = cache_get_field_content_int(0, "Name");
  87. cache_delete(res);
  88. return Name;
  89. }
  90.  
  91. stock SetPlayerClan(playerid, clanid, connectionHandle)
  92. {
  93. new query[256];
  94. format(query, sizeof(query), "UPDATE `Users` SET `Clan`= '%d' WHERE `Name` ='%s'", clanid, GetName(playerid));
  95. mysql_query(connectionHandle, query);
  96. }
  97.  
  98. stock GetPlayerClan(playerid, connectionHandle)
  99. {
  100. new string[128];
  101. format(string, sizeof(string), "SELECT Clan FROM Users WHERE Name = '%s'", GetName(playerid));
  102. new Cache: resull = mysql_query(connectionHandle, string);
  103. new ID = cache_get_field_content_int(0, "ID");
  104. cache_delete(resull);
  105. return ID;
  106. }
  107.  
  108. stock GetName(playerid)
  109. {
  110. new szName[MAX_PLAYER_NAME];
  111. GetPlayerName(playerid, szName, sizeof(szName));
  112. return szName;
  113. }
Add Comment
Please, Sign In to add comment