22.10.2018, 15:08
Hello, so I've been trying to re-create a clan system, and I'm facing an error...
Here's the code:
And then when I do /myclan ingame
It just shows Your current clan ID is: 0 while it should be 1 or 2..
Here's the code:
PHP код:
CMD:createclan(cmdid, playerid, params[])
{
if(!UserStats[playerid][Clan])
{
new clanname[32], query[300];
if(sscanf(params, "s[32]", clanname)) return SendClientMessage(playerid, COLOR_RED, "[USAGE]: /createclan [clanname]");
mysql_format(Database, query, sizeof(query), "SELECT * FROM `clans` WHERE `ClanName` = '%e'", clanname);
new Cache:result = mysql_query(Database, query);
if(cache_num_rows())
{
SendClientMessageEx(playerid, COLOR_RED, "[ERROR]: Clan name ''%s'' already exists. Pick another name.", clanname);
}
else
{
mysql_format(Database, query, sizeof(query), "INSERT INTO `clans` (`ClanName`, `ClanLeader`, `Official`) VALUES ('%e', '%e', '0')", clanname, GetName(playerid));
mysql_tquery(Database, query);
UserStats[playerid][Clan] = cache_insert_id();
new clanid = UserStats[playerid][Clan];
ClanInfo[clanid][ClanID] = clanid;
ClanInfo[clanid][ClanName] = clanname;
ClanInfo[clanid][ClanLeader] = GetName(playerid);
ClanInfo[clanid][Official] = 0;
cache_delete(result);
}
}
else
{
SendClientMessage(playerid, COLOR_RED, "[ERROR]: You already own a clan.");
}
return 1;
}
PHP код:
CMD:myclan(cmdid, playerid, params[])
{
if(!UserStats[playerid][Clan])
{
SendClientMessage(playerid, COLOR_WHITE, "You are not in a clan.");
}
else
{
SendClientMessageEx(playerid, COLOR_WHITE, "Your current clan ID is: %d", UserStats[playerid][Clan]);
}
return 1;
}