New life help
#1

So, i coded a new life system where players can use /newlife to start a new life (and resetting their stats). Everything works except the stats reset, doesn't work. It keeps old stats:

pawn Код:
public NewLife(playerid)
{
    KillTimer(NewLifeTimerr[playerid]);
    SendClientMessage(playerid, 0xFF0000FF, "** New life loaded without errors, your account stats have been resetted.");
    GameTextForPlayer(playerid, "~w~New life ~r~loaded!", 5000, 3);
   
    new pname[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pname, 24);

    new filestring[128];
    format(filestring, sizeof(filestring), "/Users/%s.ini", pname);
    {
        new INI:File = INI_Open(filestring);
        INI_SetTag(File, "Player's Data");
        INI_WriteInt(File,"Cash",0);
        INI_WriteInt(File,"Admin",0);
        INI_WriteInt(File,"Kills",0);
        INI_WriteInt(File,"Deaths",0);
        INI_WriteInt(File,"Nopm",0);
        INI_WriteInt(File,"Mute",0);
        INI_WriteInt(File,"Vip",0);
        INI_WriteInt(File,"Banned",0);
        INI_WriteInt(File,"Cookies",0);
        INI_WriteInt(File,"Warn",0);
        INI_WriteInt(File,"Jailed", 0);
        INI_WriteInt(File,"Logged", 1);
        INI_WriteInt(File,"AdminActions",0);
        INI_WriteInt(File,"Rank", 0);
        INI_WriteInt(File,"Taxes",0);
        INI_WriteInt(File,"Skill",0);
        INI_WriteInt(File,"Condoms",0);
        INI_WriteInt(File,"Infected",0);
        INI_WriteInt(File,"TempBan",0);
        INI_WriteInt(File,"PlayersRobbed",0);
        INI_WriteInt(File,"PlayersRaped",0);
        INI_WriteInt(File,"SoldVehicles",0);
        INI_WriteInt(File,"TotalRobbedMoney",0);
        INI_WriteInt(File,"PlayersInfected",0);
        INI_WriteInt(File,"CarjackerProfit",0);
        INI_WriteInt(File,"PingExceeds",0);
        INI_WriteInt(File,"Bombs",0);
        INI_WriteInt(File,"BombsPlanted",0);
        INI_WriteInt(File,"Drugs",0);
        INI_WriteInt(File,"DrugsSold",0);
        INI_WriteInt(File,"DrugsProfit",0);
        INI_WriteInt(File,"DDClientsServed",0);
        INI_WriteInt(File,"Reputation",0);
        INI_WriteInt(File,"DrugSeeds",0);
        INI_Close(File);
    }

    new echos[128];
    new am[128];
    format(echos,sizeof(echos),"0,** %s (%d) started a new life. (/newlife)",pname,playerid);
    format(am,sizeof(am),"0,2** %s (%d) started a new life. (/newlife)",pname,playerid);
    IRC_GroupSay(gGroupID, IRC_CHANNEL, echos);
    SCMTA(COLOR_CON_GREEN,am);
    return 1;
}
Reply
#2

Everything seems fine dude :/ Try restarting whole server by closing the command window, not with gmx or reloadfs.
Reply
#3

Quote:
Originally Posted by HurtLocker
Посмотреть сообщение
Everything seems fine dude :/ Try restarting whole server by closing the command window, not with gmx or reloadfs.
I use a public volthost test server and already restarted..
Reply
#4

Why you create a callback instead of creating a simple zcmd command? And what does that timer, NewLifeTimerr[playerid] which you kill, do?
Reply
#5

Quote:
Originally Posted by HurtLocker
Посмотреть сообщение
Why you create a callback instead of creating a simple zcmd command? And what does that timer, NewLifeTimerr[playerid] which you kill, do?
I created a callback because in /newlife i have a 10 seconds waiting for starting the new life, NewLifeTimerr is the timer of 10 seconds.

pawn Код:
NewLifeTimerr[playerid] = SetTimerEx("NewLife",10000,0,"i",playerid);
Reply
#6

Just for test, try to run the cmd as CMD:.... and lets see if it works. If it does, then you do something wrong with the timer, did you forward it?

EDIT: non-repeating timers do not need to be killed/cannot be killed, do they/can they?
Reply
#7

It'll write to the files but it's not actually setting the player's INFO variables to 0...
Reply
#8

Quote:
Originally Posted by Shoulen
Посмотреть сообщение
It'll write to the files but it's not actually setting the player's INFO variables to 0...
So, any help to how fix it?

Quote:
Originally Posted by HurtLocker
Посмотреть сообщение
Just for test, try to run the cmd as CMD:.... and lets see if it works. If it does, then you do something wrong with the timer, did you forward it?
EDIT: non-repeating timers do not need to be killed/cannot be killed, do they/can they?
Obv i forwarded it, otherwise i'd get errors while compiling..
Reply
#9

Dude you didnt answer about killing timer. You can't kill a non-repeating timer. Delete line KillTimer(uigi8f086rf). Also do what I said: run the command without timer to see if it actually works.
Reply
#10

I fixed in another way, only score and money weren't resetted. Thanks all.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)