12.09.2018, 09:52
PHP код:
IRCCMD:setscore(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 targetid, score, string[144];
if(sscanf(params, "ud", targetid, score)) return IRC_Notice(gGroupID, user,"\x0214[USAGE]:\x02 !setscore [player id] [score]") && IRC_Notice(gGroupID, user,"\x0214[FUNCTION]:\x02 Set a player's score");
if(!IsPlayerConnected(targetid)) return IRC_Notice(botid, user, "\x0204[ERROR]:\x02 That player is not online!");
if(IsPlayerNPC(targetid)) return IRC_Notice(botid, user, "\x0204[ERROR]:\x02 You cannot set an NPC's score!");
if(pInfo[targetid][pIsPlayerLogged] == false) IRC_Notice(botid, user, "\x0204[ERROR]:\x02 This player hasn't logged-in yet!");
if(pInfo[targetid][pIsPlayerSpawned] == false) IRC_Notice(botid, user, "\x0204[ERROR]:\x02 This player hasn't spawned yet!");
pInfo[targetid][pHours] = score;
SetPlayerScore(targetid, score);
format(string, sizeof(string), "*"COL_WHITE" %s "COL_ORANGE"has set your score to "COL_WHITE"%i", user, score);
SendClientMessage(targetid, -1, string);
format(string, sizeof(string), "*"COL_WHITE" %s "COL_ORANGE"has set "COL_WHITE"%s"COL_ORANGE"'s score to "COL_WHITE"%i", user, pInfo[targetid][pUsername], score);
SendMessageToAllAdmins(string, -1, pInfo[targetid][pAdminLevel] > 0 ? targetid : INVALID_PLAYER_ID);
format(string, sizeof(string), "\x0203[INFO]:\x02 \x1D%s\x1D has set \x1D%s\x1D's score to \x1D%d\x1D", user, pInfo[targetid][pUsername], score);
IRC_GroupSay(gGroupID, channel, string);
SendToLog("/setscore", user, pInfo[targetid][pUsername], score);
return 1;
}
This is the other one for /setoffscore, for offline players. This one works.
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], score, _query[120];
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!");
format(_query, sizeof(_query), "UPDATE `accounts` SET `Hours` = %d WHERE `Username` = '%s'", 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;
}