Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- sclan.inc by Shinja
- All copyrights reserved
- Do not edit, even bugs
- Report to original developer
- Requirements:
- MySQL R39-5 by BlueG
- http://forum.sa-mp.com/showthread.php?t=56564
- */
- #include <a_samp>
- #include <a_mysql>
- native Shinja_CreateClan(name[], connectionHandle);
- native Shinja_DestroyClan(clanid, connectionHandle);
- native Shinja_IsClanExists(clanid, connectionHandle);
- native Shinja_IsClanNameExists(name[], connectionHandle);
- native Shinja_GetClanID(name[], connectionHandle);
- native Shinja_GetClanName(clanid, connectionHandle);
- native Shinja_GetPlayerClan(playerid, connectionHandle);
- native Shinja_SetPlayerClan(playerid, clanid, connectionHandle);
- native Shinja_IsPlayerInAnyClan(playerid, connectionHandle);
- stock IsPlayerInAnyClan(playerid, connectionHandle)
- {
- new string[128];
- format(string, sizeof(string), "SELECT Clan FROM Users WHERE Name = '%s'", GetName(playerid));
- new Cache:resultt = mysql_query(connectionHandle, string);
- new value = cache_get_field_content_int(0, "Clan");
- cache_delete(resultt);
- if(value == -1) return false;
- else return true;
- }
- stock CreateClan(name[], connectionHandle)
- {
- new string[128];
- format(string, sizeof(string), "INSERT INTO Clans (Name) VALUES ('%s')", name);
- mysql_query(connectionHandle, string);
- }
- stock DestroyClan(clanid, connectionHandle)
- {
- new string[128];
- format(string, sizeof(string), "DELETE FROM Clans WHERE ID = '%d'", clanid);
- mysql_query(connectionHandle, string);
- }
- stock IsClanExists(clanid, connectionHandle)
- {
- new string[128];
- format(string, sizeof(string), "SELECT * FROM Clans WHERE ID = '%d'", clanid);
- new Cache:resultt = mysql_query(connectionHandle, string);
- new value = cache_num_rows();
- cache_delete(resultt);
- return value;
- }
- stock IsClanNameExists(name[], connectionHandle)
- {
- new string[128];
- format(string, sizeof(string), "SELECT * FROM Clans WHERE Name = '%s'", name);
- new Cache:resultt = mysql_query(connectionHandle, string);
- new value = cache_num_rows();
- cache_delete(resultt);
- return value;
- }
- stock GetClanID(name[], connectionHandle)
- {
- new string[128];
- format(string, sizeof(string), "SELECT ID FROM Clans WHERE Name = '%s'", name);
- new Cache: resull = mysql_query(connectionHandle, string);
- new ID = cache_get_field_content_int(0, "ID");
- cache_delete(resull);
- return ID;
- }
- stock GetClanName(clanid, connectionHandle)
- {
- new string[128];
- format(string, sizeof(string), "SELECT Name FROM Clans WHERE ID = '%d'", clanid);
- new Cache: res = mysql_query(string, connectionHandle);
- new Name = cache_get_field_content_int(0, "Name");
- cache_delete(res);
- return Name;
- }
- stock SetPlayerClan(playerid, clanid, connectionHandle)
- {
- new query[256];
- format(query, sizeof(query), "UPDATE `Users` SET `Clan`= '%d' WHERE `Name` ='%s'", clanid, GetName(playerid));
- mysql_query(connectionHandle, query);
- }
- stock GetPlayerClan(playerid, connectionHandle)
- {
- new string[128];
- format(string, sizeof(string), "SELECT Clan FROM Users WHERE Name = '%s'", GetName(playerid));
- new Cache: resull = mysql_query(connectionHandle, string);
- new ID = cache_get_field_content_int(0, "ID");
- cache_delete(resull);
- return ID;
- }
- stock GetName(playerid)
- {
- new szName[MAX_PLAYER_NAME];
- GetPlayerName(playerid, szName, sizeof(szName));
- return szName;
- }
Add Comment
Please, Sign In to add comment