CallBackFunction MYSQL cached
#10

@Gammix.
It updates my faction name, however it fucked with my factionid. So faction ID are A_I. I'm trying to give my faction name a specific ID and update it both on `account` and `faction` table. under account the colum is called `factionid` and similarly under `faction` it's called `factionid`.

Player[playerid][FactionID] = cache_insert_id(); ->Faction ID.
PHP код:
case factionnamed:
        {
            new 
bool:success true;
            
format(Player[playerid][FactionName], 120inputtext);
            new 
query[200];
            
mysql_format(mysqlquerysizeof (query), "INSERT INTO `faction` (`factionname`) VALUES ('%e')"inputtext);
            if (
mysql_tquery(mysqlquery) == 0)
                
success false;
            
mysql_format(mysqlquerysizeof (query), "UPDATE `accounts` SET `factionname` = '%e', `factionid` = %d WHERE `ID` =  %d LIMIT 1"Player[playerid][FactionName], Faction[playerid][ID], Player[playerid][ID]);
            if (
mysql_tquery(mysqlquery) == 0)
                
success false;
            if (
success)
            {
                
Faction[playerid][ID] = cache_insert_id();
                
printf("[INFO] New faction created. Database ID: [%d]"Faction[playerid][ID]);
                
ShowPlayerDialog(playeridfactiontypedDIALOG_STYLE_LIST"FACTION CREATION""Type 0(Drugs)\nType 1(Weapons)""Choose","Cancel");
            }
            else
            {
                
// Either a new row in "faction" table wasn't created or `accounts` wasn't updated
            
}
        }
        case 
factiontyped:
        {
            if(
response)
                {
                    switch(
listitem)
                    {
                        
//mysql_format(mysql,query,sizeof(query), "UPDATE `accounts` SET `Admin` = %d WHERE ID = %d LIMIT 1",  level, Player[target][ID]);
                        
case 0:
                        {
                            new 
query[500];
                            new 
str[250];
                            
format(str,sizeof(str), "FACTION CREATED %s"Player[playerid][FactionName]);
                            
SendClientMessage(playerid,COLOR_GREY,str);
                            
SendClientMessage(playeridCOLOR_GREY"[INFO] FACTION CREATED!(Drug Warehouse)");
                            
Player[playerid][FactionID] = Faction[playerid][ID];
                            
mysql_format(mysqlquery,sizeof(query), "UPDATE `faction` SET `factiontype` = '0' WHERE ID = %d LIMIT 1"Player[playerid][FactionID]);
                            
mysql_tquery(mysqlquery"""");
                            
                        }
                        
                        case 
1:
                        {
                            new 
query[500];
                            
SendClientMessage(playeridCOLOR_GREY"[INFO] FACTION CREATED!(Gun Warehouse)");
                            
Player[playerid][FactionID] = Faction[playerid][ID];
                             
mysql_format(mysqlquery,sizeof(query), "UPDATE `faction` SET `factiontype` = '1' WHERE ID = %d LIMIT 1",Player[playerid][FactionID]);
                            
mysql_tquery(mysqlquery"""");
                        }
                    }
                }
        } 
Because I'm trying to update faction type, set 0 or 1, depending on what user choose. and then I use WHERE ID %d which signifies to my faction ID. It doesn't update anymore because there is something funky with my faction ID.
However when I use /createfaction -> it creates the faction with a ID. But when I choose the type, it doesn't update.
In short and simple, I'm trying to assign Player[playerid][FactionID] to the A_I created under `faction` table with the name `factionid` so I can just call Player[playerid][FactionID] which will return me the player faction ID.

Also, What if I'd like to load data from `faction` table. How do I use cache_get_data_int and cache_get_data to retrieve items from fields,rows.
Reply


Messages In This Thread
CallBackFunction MYSQL cached - by DavidLuango - 30.07.2016, 09:29
Re: CallBackFunction MYSQL cached - by DavidLuango - 30.07.2016, 16:13
Re: CallBackFunction MYSQL cached - by Gammix - 30.07.2016, 16:19
Re: CallBackFunction MYSQL cached - by DavidLuango - 30.07.2016, 16:41
Re: CallBackFunction MYSQL cached - by DavidLuango - 30.07.2016, 16:54
Re: CallBackFunction MYSQL cached - by DavidLuango - 30.07.2016, 18:03
Re: CallBackFunction MYSQL cached - by Gammix - 30.07.2016, 18:36
Re: CallBackFunction MYSQL cached - by Konstantinos - 30.07.2016, 19:02
Re: CallBackFunction MYSQL cached - by Gammix - 30.07.2016, 19:12
Re: CallBackFunction MYSQL cached - by DavidLuango - 30.07.2016, 21:05

Forum Jump:


Users browsing this thread: 3 Guest(s)