Clan command shows ID 0 instead of anything else
#1

Hello, so I've been trying to re-create a clan system, and I'm facing an error...

Here's the code:

PHP код:
CMD:createclan(cmdidplayeridparams[])
{
    if(!
UserStats[playerid][Clan])
    {
        new 
clanname[32], query[300];
        if(
sscanf(params"s[32]"clanname)) return SendClientMessage(playeridCOLOR_RED"[USAGE]: /createclan [clanname]");
        
mysql_format(Databasequerysizeof(query), "SELECT * FROM `clans` WHERE `ClanName` = '%e'"clanname);
        new 
Cache:result mysql_query(Databasequery);
        if(
cache_num_rows())
        {
            
SendClientMessageEx(playeridCOLOR_RED"[ERROR]: Clan name ''%s'' already exists. Pick another name."clanname);
        }
        else
        {
            
mysql_format(Databasequerysizeof(query), "INSERT INTO `clans` (`ClanName`, `ClanLeader`, `Official`) VALUES ('%e', '%e', '0')"clannameGetName(playerid));
            
mysql_tquery(Databasequery);
            
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(playeridCOLOR_RED"[ERROR]: You already own a clan.");
    }
    return 
1;

And then when I do /myclan ingame

PHP код:
CMD:myclan(cmdidplayeridparams[])
{
    if(!
UserStats[playerid][Clan])
    {
        
SendClientMessage(playeridCOLOR_WHITE"You are not in a clan.");
    }
    else
    {
        
SendClientMessageEx(playeridCOLOR_WHITE"Your current clan ID is: %d"UserStats[playerid][Clan]);
    }
    return 
1;

It just shows Your current clan ID is: 0 while it should be 1 or 2..
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 4 Guest(s)