Not updating -
StR_MaRy - 17.08.2017
Hey guys i have a new gamemode but the stats are not updating mysql version ins R41-2
Код HTML:
enum pInfo
{
pSQLID, pName[MAX_PLAYERS], pPassword, pAge, pAdmin, pHelper, pMoney
};
new PlayerInfo[MAX_PLAYERS][pInfo];
public Update(playerid, type)
{
if(IsPlayerConnected(playerid))
{
new query1[255];
{
switch(type)
{
case pAdminx:
{
mysql_format(g_Sql, query1, sizeof(query1), "UPDATE `users` SET `Admin` = '%d' WHERE `ID` = '%d'", PlayerInfo[playerid][pAdmin], PlayerInfo[playerid][pSQLID]);
mysql_tquery(g_Sql, query1, "", "");
}
case pMoneyx:
{
mysql_format(g_Sql, query1, sizeof(query1), "UPDATE `users` SET `Money` = '%d' WHERE `Name` = '%s'", PlayerInfo[playerid][pMoney], PlayerInfo[playerid][pName]);
mysql_tquery(g_Sql, query1, "", "");
}
}
}
}
return 1;
}
And the command
Код HTML:
CMD:makeadmin(playerid, params[])
{
new strglobal[856];
//if(PlayerInfo[playerid][pAdmin] < 6) return SCM(playerid, -1, "Nu ai gradul necesar pentru a folosi aceasta comanda.");
new giveplayerid, adminlevel;
if(sscanf(params, "ui", giveplayerid, adminlevel)) return SCM(playerid, -1, "/makeadmin <Name/PlayerID> <0-5>");
if(giveplayerid == INVALID_PLAYER_ID) return SCM(playerid, -1, "/makeadmin <Name/PlayerID> <0-5>");
if(adminlevel > 0 || adminlevel < 6)
{
format(strglobal, sizeof(strglobal), "* Congratulations %s for becoming Administrator Rank %d.", GetName(giveplayerid), adminlevel);
SCMALL(-1, strglobal);
format(strglobal, sizeof(strglobal), "%s has made %s a admin (%d).", GetName(playerid), GetName(giveplayerid), adminlevel);
SCM(playerid, -1, strglobal);
new text[456];
format(text,456, "AdmBot: {FFFFFF}%s has made %s a admin (%d).", GetName(playerid), GetName(giveplayerid), adminlevel);
SCM(giveplayerid, -1, text);
SCM(giveplayerid, -1, "AdmBot: {FFFFFF}You can use [/ah] for commands list.");
}
if(adminlevel == 0)
{
format(strglobal, sizeof(strglobal), "%s stripped %s of his admin rank.", GetName(playerid), GetName(giveplayerid));
SCM(playerid, -1, strglobal);
new text[456];
format(text,456, "AdmBot: {FFFFFF}%s stripped %s of his admin rank.", GetName(playerid), GetName(giveplayerid));
SCM(giveplayerid, -1, text);
}
PlayerInfo[giveplayerid][pAdmin] = adminlevel;
Update(giveplayerid, pAdminx);
PlayerInfo[giveplayerid][pMoney] = 14434;
Update(giveplayerid, pMoneyx);
//mysql_format(g_Sql, query, sizeof(query), "UPDATE `users` SET `Admin` = '%d' WHERE `Name` = '%e'", adminlevel, GetName(toplayerid));
//mysql_query(g_Sql, query);
return 1;
}
it can update with this only
Код HTML:
//mysql_format(g_Sql, query, sizeof(query), "UPDATE `users` SET `Admin` = '%d' WHERE `Name` = '%e'", adminlevel, GetName(toplayerid));
//mysql_query(g_Sql, query);
but not with this
Код HTML:
PlayerInfo[giveplayerid][pAdmin] = adminlevel;
Update(giveplayerid, pAdminx);
Re: Not updating -
10MIN - 17.08.2017
pAdminx or pMoneyx are even defined? With #define? Because a switch statement uses integers...
Re: Not updating -
StR_MaRy - 17.08.2017
yes i didn't mention them
Код HTML:
#define pAdminx 1
#define pMoneyx 2
Re: Not updating -
JesterlJoker - 17.08.2017
First of all Update does not really need to public or forward on your scenario you can just make that into a function,
Second of all why would you use pSQLID, on the adminx and pName on MoneyX? that's a little bit of confusing for both you and the readers.
Third of all
PHP код:
mysql_tquery(something here, something here, "", "");
<- if you are not using the last two parts don't add the quotes, it just makes the process read the empty quotes and empty quotes would give out a value of 0 rather than letting the query think that it's a default -1.
Hope that helps
PHP код:
enum pInfo
{
pSQLID, pName[MAX_PLAYERS], pPassword, pAge, pAdmin, pHelper, pMoney
};
new PlayerInfo[MAX_PLAYERS][pInfo];
public Update(playerid, type)
{
if(IsPlayerConnected(playerid))
{
new query1[255];
{
switch(type)
{
case pAdminx:
{
mysql_format(g_Sql, query1, sizeof(query1), "UPDATE `users` SET `Admin` = '%d' WHERE `ID` = '%d'", PlayerInfo[playerid][pAdmin], PlayerInfo[playerid][pSQLID]);
mysql_tquery(g_Sql, query1, "", "");
}
case pMoneyx:
{
mysql_format(g_Sql, query1, sizeof(query1), "UPDATE `users` SET `Money` = '%d' WHERE `Name` = '%s'", PlayerInfo[playerid][pMoney], PlayerInfo[playerid][pName]);
mysql_tquery(g_Sql, query1, "", "");
}
}
}
}
return 1;
}
If it doesn't then, I have no more help to add..
Re: Not updating -
StR_MaRy - 17.08.2017
Yea it helped, thx i solved and it worked
Код HTML:
function Update(playerid, type)
{
if(IsPlayerConnected(playerid))
{
query[0] = (EOS);
{
switch(type)
{
case pAdminx:
{
mysql_format(g_Sql, query, sizeof(query), "UPDATE `users` SET `Admin` = '%d'", PlayerInfo[playerid][pAdmin]);
mysql_query(g_Sql, query);
}
case pMoneyx:
{
mysql_format(g_Sql, query, sizeof(query), "UPDATE `users` SET `Money` = '%d'", PlayerInfo[playerid][pMoney]);
mysql_query(g_Sql, query);
}
}
}
}
return 1;
}
Thx +1 rep