17.01.2019, 11:35
(
Последний раз редактировалось DarkMythHunter; 18.01.2019 в 05:27.
)
So as the title says, that's where I need help at.
I have this command called !setoffscore, this is for IRC:
I want to also set it from "stats" since we wanted to save "Hours" in 2 different tables ( there's other purpose behind it ) but the thing is we don't use "Username" on "stats" Instead, we use the AccountID of the Username from the table "accounts"
I've tried this:
But it didn't worked, can you help me fix it, or at least figure out/help me out? Thanks. +rep for helping.
I have this command called !setoffscore, this is for IRC:
PHP код:
IRCCMD:setoffscore(botid, channel[], user[], host[], params[])
{
if(!IRC_IsAdmin(botid, channel, user)) return IRC_Notice(botid, user, "\x0204[ERROR]:\x02 You are don't have permission to use this command!");
if(!IsPlayerWhiteList(user)) return IRC_Notice(botid, user, "\x0204[ERROR]:\x02 You are don't have permission to use this command!");
new targetName[MAX_PLAYER_NAME], _query[150], score, Cache:results;
if(sscanf(params, "s[24]d", score)) return IRC_Notice(gGroupID, user,"\x0214[USAGE]:\x02 !setoffscore [username] [score]") && IRC_Notice(gGroupID, user,"\x0214[FUNCTION]:\x0F Set an offline player's score");
if(IsValidAccount(targetName) == 0) return IRC_Notice(botid, user, "\x0204[ERROR]:\x02 You have inputed an invalid account name!");
format(_query, sizeof(_query), "UPDATE `accounts` SET `Hours` = %d WHERE `Username` = '%e'", score, targetName);
mysql_tquery(handle, _query);
format(_query, sizeof(_query), "\x0203[INFO]:\x02 \x1D%s\x1D has set \x1D%s\x1D's score to \x1D%d\x1D", user, targetName, score);
IRC_GroupSay(gGroupID, channel, _query);
SendToLog("!setscore", user, targetName, score);
return 1;
}
I've tried this:
PHP код:
IRCCMD:setoffscore(botid, channel[], user[], host[], params[])
{
if(!IRC_IsAdmin(botid, channel, user)) return IRC_Notice(botid, user, "\x0204[ERROR]:\x02 You are don't have permission to use this command!");
if(!IsPlayerWhiteList(user)) return IRC_Notice(botid, user, "\x0204[ERROR]:\x02 You are don't have permission to use this command!");
new targetName[MAX_PLAYER_NAME], _query[150], score, targetId, Cache:results;
if(sscanf(params, "s[24]d", targetName, score)) return IRC_Notice(gGroupID, user,"\x0214[USAGE]:\x02 !setoffscore [username] [score]") && IRC_Notice(gGroupID, user,"\x0214[FUNCTION]:\x0F Set an offline player's score");
if(IsValidAccount(targetName) == 0) return IRC_Notice(botid, user, "\x0204[ERROR]:\x02 You have inputed an invalid account name!");
mysql_format(handle, _query, sizeof(_query), "SELECT `AccountID` FROM `accounts` WHERE `Username` = '%e'", targetName);
results = mysql_query(handle, _query);
cache_get_value_name_int(0, "AccountID", targetId);
cache_delete(results);
format(_query, sizeof(_query), "UPDATE `accounts` SET `Hours` = %d WHERE `Username` = '%e'", score, targetName);
mysql_tquery(handle, _query);
format(_query, sizeof(_query), "UPDATE `stats` SET `Hours` = %d WHERE `AccountID` = '%d'", score, targetId);
mysql_tquery(handle, _query);
format(_query, sizeof(_query), "\x0203[INFO]:\x02 \x1D%s\x1D has set \x1D%s\x1D's score to \x1D%d\x1D", user, targetName, score);
IRC_GroupSay(gGroupID, channel, _query);
SendToLog("!setscore", user, targetName, score);
return 1;
}