30.07.2016, 21:05
(
Последний раз редактировалось DavidLuango; 30.07.2016 в 21:47.
)
@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.
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.
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], 120, inputtext);
new query[200];
mysql_format(mysql, query, sizeof (query), "INSERT INTO `faction` (`factionname`) VALUES ('%e')", inputtext);
if (mysql_tquery(mysql, query) == 0)
success = false;
mysql_format(mysql, query, sizeof (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(mysql, query) == 0)
success = false;
if (success)
{
Faction[playerid][ID] = cache_insert_id();
printf("[INFO] New faction created. Database ID: [%d]", Faction[playerid][ID]);
ShowPlayerDialog(playerid, factiontyped, DIALOG_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(playerid, COLOR_GREY, "[INFO] FACTION CREATED!(Drug Warehouse)");
Player[playerid][FactionID] = Faction[playerid][ID];
mysql_format(mysql, query,sizeof(query), "UPDATE `faction` SET `factiontype` = '0' WHERE ID = %d LIMIT 1", Player[playerid][FactionID]);
mysql_tquery(mysql, query, "", "");
}
case 1:
{
new query[500];
SendClientMessage(playerid, COLOR_GREY, "[INFO] FACTION CREATED!(Gun Warehouse)");
Player[playerid][FactionID] = Faction[playerid][ID];
mysql_format(mysql, query,sizeof(query), "UPDATE `faction` SET `factiontype` = '1' WHERE ID = %d LIMIT 1",Player[playerid][FactionID]);
mysql_tquery(mysql, query, "", "");
}
}
}
}
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.