It don't change the data on database
#1

PHP код:
IRCCMD:setscore(botidchannel[], user[], host[], params[])
{
    if(!
IRC_IsAdmin(botidchanneluser)) return IRC_Notice(botiduser"\x0204[ERROR]:\x02 You are don't have permission to use this command!");
    if(!
IsPlayerWhiteList(user)) return IRC_Notice(botiduser"\x0204[ERROR]:\x02 You are don't have permission to use this command!");
    new 
targetidscorestring[144];
    if(
sscanf(params"ud"targetidscore)) return IRC_Notice(gGroupIDuser,"\x0214[USAGE]:\x02 !setscore [player id] [score]") && IRC_Notice(gGroupIDuser,"\x0214[FUNCTION]:\x02 Set a player's score");
    if(!
IsPlayerConnected(targetid)) return IRC_Notice(botiduser"\x0204[ERROR]:\x02 That player is not online!");
    if(
IsPlayerNPC(targetid)) return IRC_Notice(botiduser"\x0204[ERROR]:\x02 You cannot set an NPC's score!");
       if(
pInfo[targetid][pIsPlayerLogged] == falseIRC_Notice(botiduser"\x0204[ERROR]:\x02 This player hasn't logged-in yet!");
    if(
pInfo[targetid][pIsPlayerSpawned] == falseIRC_Notice(botiduser"\x0204[ERROR]:\x02 This player hasn't spawned yet!");
    
pInfo[targetid][pHours] = score;
    
SetPlayerScore(targetidscore);
    
format(stringsizeof(string), "*"COL_WHITE" %s "COL_ORANGE"has set your score to "COL_WHITE"%i"userscore);
    
SendClientMessage(targetid, -1string);
    
format(stringsizeof(string), "*"COL_WHITE" %s "COL_ORANGE"has set "COL_WHITE"%s"COL_ORANGE"'s score to "COL_WHITE"%i"userpInfo[targetid][pUsername], score);
    
SendMessageToAllAdmins(string, -1pInfo[targetid][pAdminLevel] > targetid INVALID_PLAYER_ID);
    
format(stringsizeof(string), "\x0203[INFO]:\x02 \x1D%s\x1D has set \x1D%s\x1D's score to \x1D%d\x1D"userpInfo[targetid][pUsername], score);
    
IRC_GroupSay(gGroupIDchannelstring);
    
SendToLog("/setscore"userpInfo[targetid][pUsername], score);
    return 
1;

This one don't work correctly, it do changes the online player score but it does not change the data in the database. So if the player logged off, and logged in the old score will still load.



This is the other one for /setoffscore, for offline players. This one works.

PHP код:
IRCCMD:setoffscore(botidchannel[], user[], host[], params[])
{
    if(!
IRC_IsAdmin(botidchanneluser)) return IRC_Notice(botiduser"\x0204[ERROR]:\x02 You are don't have permission to use this command!");
    if(!
IsPlayerWhiteList(user)) return IRC_Notice(botiduser"\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"targetNamescore)) return IRC_Notice(gGroupIDuser,"\x0214[USAGE]:\x02 !setoffscore [username] [score]") && IRC_Notice(gGroupIDuser,"\x0214[FUNCTION]:\x0F Set an offline player's score");
    if(
IsValidAccount(targetName) == 0) return IRC_Notice(botiduser"\x0204[ERROR]:\x02 You have inputed an invalid account name!");
    
format(_querysizeof(_query), "UPDATE `accounts` SET `Hours` = %d WHERE `Username` = '%s'"scoretargetName);
    
mysql_tquery(handle_query);
    
format(_querysizeof(_query), "\x0203[INFO]:\x02 \x1D%s\x1D has set \x1D%s\x1D's score to \x1D%d\x1D"usertargetNamescore);
    
IRC_GroupSay(gGroupIDchannel_query);
    
SendToLog("!setscore"usertargetNamescore);
    return 
1;

Reply
#2

Код:
    format(_query, sizeof(_query), "UPDATE `accounts` SET `Hours` = %d WHERE `Reg_ID` = '%d'", score, pInfo[targetid][pRegID]);
    mysql_tquery(handle, _query);
Instead of Reg_ID and pInfo[targetid][pRegID], use your users reg ids column name and Reg variable. Use this code at the bottm of the /setscore command.
Reply
#3

This is not how saving works, with set score you're supposed to save the score in a local variable that's all.

The saving / loading system should do the rest. (Normally you load userdata on login into local variables and then save those variables again to mysql when player leaves).
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)