Timer problem
#1

Hello guys , i have an exp sistem wich gives you 1 exp every minute,and when you make 60 minutes you can get your payday and when you make the EXP needed for level up ,example for level 5 aprox~ 200 exp ,you level up.

The problem is,its not working,1 minute passes,but exp is the same.

ongamemodeinit i have
PHP код:
usetimer SetTimer("UsedTimer"600001); 
then the killtimer at ongamemodexit.

This is the function

look just at the exp thing
PHP код:
function UsedTimer()
{
    new 
str[256], string[128];
     for(new 
1sizeof(Turfs); i++)
    {
        if(
WarInfo[i][wTime] > 0)
        {
            
WarInfo[i][wTime] -= 1;
            new 
attackers WarInfo[i][wAttacker];
            new 
defenders WarInfo[i][wFaction];
            foreach(
Playerj)
            {
                if(
IsPlayerInTurf(j,i) == 1)
                {
                    if((
PlayerData[j][Member] + PlayerData[j][Leader]) == attackers)
                    {
                        
WarScore[j][i] +=  1;
                    }
                    if((
PlayerData[j][Member] + PlayerData[j][Leader]) == defenders)
                    {
                        
WarScore[j][i] += 1;
                    }
                }
            }
            if(
WarInfo[i][wTime] == 1)
            {
                new 
atscore 0;
                new 
defscore 0;
                new 
winner;
                foreach(
Playerj)
                {
                    if((
PlayerData[j][Member] + PlayerData[j][Leader]) == attackers)
                    {
                        
WarScore[j][i] /= 10;
                        
atscore += WarScore[j][i];
                        
GangZoneStopFlashForPlayer(j,Turfs[i]);
                        
format(string,sizeof(string),"The war between %s and %s for turf %d ended. Calculating the score...",FactionName(attackers),FactionName(defenders),i);
                        
SendClientMessage(jTEAM_AZTECAS_COLOR,string);
                    }
                    if((
PlayerData[j][Member] + PlayerData[j][Leader]) == defenders)
                    {
                        
WarScore[j][i] /= 10;
                        
defscore += WarScore[j][i];
                        
GangZoneStopFlashForPlayer(j,Turfs[i]);
                        
format(string,sizeof(string),"The war between %s and %s for turf %d ended. Calculating the score...",FactionName(attackers),FactionName(defenders),i);
                        
SendClientMessage(jTEAM_AZTECAS_COLOR,string);
                    }
                }
                
War[attackers] = 0;
                
War[defenders] = 0;
                
                if(
atscore >= defscore)
                    
winner 1;
                if(
defscore atscore)
                    
winner 2;
                foreach(
Playerj)
                {
                    if(((
PlayerData[j][Member] + PlayerData[j][Leader]) == attackers) || ((PlayerData[j][Member] + PlayerData[j][Leader]) == defenders))
                    {
                        if(
winner == 1)
                        {
                            
format(string,sizeof(string),"%s won turf %d Score: %s %i | %i %s",FactionName(WarInfo[i][wAttacker]),i,FactionName(WarInfo[i][wAttacker]),atscore,defscore,FactionName(WarInfo[i][wFaction]));
                            
SendClientMessage(jTEAM_AZTECAS_COLOR,string);
                            new 
score WarScore[j][i];
                            
format(string,sizeof(string),"Your score was: %i (%i deaths)"scoreWarDeaths[j][i]);
                            
SendClientMessage(jTEAM_AZTECAS_COLOR,string);
                            
TurfInfo[i][zOwned] = WarInfo[i][wAttacker];
                            
                            
mysql_format(SQLstr,256,"UPDATE `turfs` SET `Owned`='%d' WHERE `ID`='%d'",WarInfo[i][wAttacker],i);
                            
mysql_tquery(SQLstr"""");
                            
                            
//Change
                        
}
                        if(
winner == 2)
                        {
                            
format(string,sizeof(string),"%s won turf %d Score: %s %i | %i %s",FactionName(WarInfo[i][wFaction]),i,FactionName(WarInfo[i][wFaction]),defscore,atscore,FactionName(WarInfo[i][wAttacker]));
                            
SendClientMessage(jTEAM_AZTECAS_COLOR,string);
                            new 
score WarScore[j][i];
                            
format(string,sizeof(string),"Your score was: %i (%i deaths)"scoreWarDeaths[j][i]);
                            
SendClientMessage(jTEAM_AZTECAS_COLOR,string);
                        }
                        
WarScore[j][i] = 0;
                        
WarDeaths[j][i] = 0;
                    }
                    
GangZoneHideForPlayer(j,i);
                    if(
TurfInfo[i][zOwned] == 2)
                    {
                        
GangZoneShowForPlayer(jTurfs[i], TurfColorGrove);
                    }
                    if(
TurfInfo[i][zOwned] == 3)
                    {
                        
GangZoneShowForPlayer(jTurfs[i], TurfColorGSW);
                    }
                    if(
TurfInfo[i][zOwned] == 4)
                    {
                        
GangZoneShowForPlayer(jTurfs[i], TurfColorVNE);
                    }
                }
                
WarInfo[i][wTime] = 0;
                
WarInfo[i][wFaction] = 0;
                
WarInfo[i][wAttacker] = 0;
                if(
winner == 1)
                {
                    
SafeBox[attackers][sbMoney] += WarInfo[i][wPrice];
                    
SafeBox[defenders][sbMoney] -= WarInfo[i][wPrice];
                    
                    
format(stringsizeof(string), "withdraw %d money (WAR)."WarInfo[i][wPrice]);
                    
SafeboxLog(defenders,-1,string);
                    
                    
format(stringsizeof(string), "deposit %d money (WAR)."WarInfo[i][wPrice]);
                    
SafeboxLog(attackers,-1,string);
                }
                if(
winner == 2)
                {
                    
SafeBox[attackers][sbMoney] -= WarInfo[i][wPrice];
                    
SafeBox[defenders][sbMoney] += WarInfo[i][wPrice];
                    
                    
format(stringsizeof(string), "withdraw %d money (WAR)."WarInfo[i][wPrice]);
                    
SafeboxLog(attackers,-1,string);
                    
                    
format(stringsizeof(string), "deposit %d money (WAR)."WarInfo[i][wPrice]);
                    
SafeboxLog(defenders,-1,string);
                }
                
                
mysql_format(SQLstr,128,"UPDATE `safeboxs` SET `Money`='%d' WHERE `ID`='%d'",SafeBox[attackers][sbMoney], attackers);
                
mysql_tquery(SQLstr"""");
                
mysql_format(SQLstr,128,"UPDATE `safeboxs` SET `Money`='%d' WHERE `ID`='%d'",SafeBox[defenders][sbMoney], defenders);
                
mysql_tquery(SQLstr"""");
            }
        }
    }
    new 
hoursminutesyearmonthday;
    new 
datestr[128], timestr[32];
    
gettime(hoursminutes);
    
getdate(yearmonthday);
    
format(datestr,128,"%02d.%02d.%d"daymonthyear);
    
format(timestr,32,"%02d:%02d",hours,minutes);
    
TextDrawSetString(txtTimeDisp,timestr);
    
TextDrawSetString(txtDateDisp,datestr);
    
    if(
minutes == || minutes == 30)
    {
        
RandomEvent();
        
SetWorldTime(hours);
    }
    
    foreach(
Playeri)
    {
        new 
Float:health;
        
GetPlayerHealth(ihealth);
        
SetPlayerHealth(ihealth-1.0);
        if(
PlayerData[i][TrackLose] >= 0)
        {
            if(
PlayerData[i][WantedLevel] == 0)
            {
                
PlayerData[i][TrackLose] = -1;
            }
            else
            {
                
PlayerData[i][TrackLose] -= 1;
                
mysql_format(SQLstr,128,"UPDATE `users` SET `TrackLose`='%d' WHERE `ID`='%d' LIMIT 1",PlayerData[i][TrackLose],PlayerData[i][ID]);
                
mysql_tquery(SQLstr"""");
            }
            if(
PlayerData[i][TrackLose] == 0)
            {
                
PlayerData[i][WantedLevel] -= 1;
                
SetPlayerWantedLevel(i,PlayerData[i][WantedLevel]);
                
mysql_format(SQLstr,128,"UPDATE `users` SET `WantedLevel`='%d' WHERE `ID`='%d' LIMIT 1",PlayerData[i][WantedLevel],PlayerData[i][ID]);
                
mysql_tquery(SQLstr"""");
                
                
SendClientMessage(iCOLOR_WHITE,"{5181EE}Wanted: {FFFFFF}You lose 1 wanted level.");
                
format(stringsizeof(string), "HQ: Suspect %s lose 1 wanted level, current wanted level: %d."PlayerData[i][Name],PlayerData[i][WantedLevel]);
                
SendRadioMessage(10x3350FFFFstring);
                
                if(
PlayerData[i][WantedLevel] == 0)
                {
                    
SendClientMessage(iCOLOR_WHITE,"{5181EE}Wanted: {FFFFFF}You lose all stars.");
                    
format(stringsizeof(string), "HQ: Suspect %s losed all wanted levels."PlayerData[i][Name]);
                    
SendRadioMessage(10x3350FFFFstring);
                    
PlayerData[i][MDC] = 0;
                }
                else
                {
                    
PlayerData[i][TrackLose] = 30;
                }
            }
        }
        if(
IsPlayerPaused(i) == false && PlayerData[i][IsLoggedIn] == true && PlayerAFK[i] == && Sleeping[i] == 0)
        {
            
PlayerData[i][Exp] += 1;
            
OnExp[i] += 1;
            if(
OnExp[i] >= 60)
            {
                new 
checks PlayerData[i][Level] * 300;
                new 
account PlayerData[i][Bank];
                new 
interest account 300;
                
PlayerData[i][Bank] += interest;
                if(
PlayerData[i][FPunish] > 0PlayerData[i][FPunish] -= 1;
                
SendClientMessage(iCOLOR_WHITE"________ BANK STATEMENT ________");
                
format(stringsizeof(string), "  Paycheck: $%s"Decimal(checks));
                
SendClientMessage(iCOLOR_GRAD1string);
                
format(stringsizeof(string), "  Old Balance: $%s | Interest rate: 0.1%%"Decimal(account));
                
SendClientMessage(iCOLOR_GRAD1string);
                
format(stringsizeof(string), "  New balance: $%s"Decimal(PlayerData[i][Bank]));
                
SendClientMessage(iCOLOR_GRAD5string);
                
GivePlayerCash(ichecks);
                
                
mysql_format(SQLstr,128,"UPDATE `users` SET `Bank`='%d',`FPunish`='%d' WHERE `ID`='%d' LIMIT 1",PlayerData[i][Bank],PlayerData[i][FPunish],PlayerData[i][ID]);
                
mysql_tquery(SQLstr"""");
                
                
OnExp[i] = 0;
            }
            
            
PlayerData[i][TotalExp] += 1;
            
            
mysql_format(SQLstr,128,"UPDATE `users` SET `Exp`='%d',`TotalXP`='%d',`OnExp`='%d' WHERE `ID`='%d' LIMIT 1",PlayerData[i][Exp],PlayerData[i][TotalExp],OnExp[i],PlayerData[i][ID]);
            
mysql_tquery(SQLstr"""");
            
            if(
PlayerData[i][CarLic] > 0PlayerData[i][CarLic] -= 1;
            if(
PlayerData[i][FlyLic] > 0PlayerData[i][FlyLic] -= 1;
            if(
PlayerData[i][BoatLic] > 0PlayerData[i][BoatLic] -= 1;
            if(
PlayerData[i][FishLic] > 0PlayerData[i][FishLic] -= 1;
            if(
PlayerData[i][GunLic] > 0PlayerData[i][GunLic] -= 1;
            if(
PlayerData[i][MatsLic] > 0PlayerData[i][MatsLic] -= 1;
            if(
PlayerData[i][CarLic] == 10SendClientMessage(iRED"WARNING: Your driving license will expire in 10 minutes.");
            if(
PlayerData[i][FlyLic] == 10SendClientMessage(iRED"WARNING: Your flying license will expire in 10 minutes.");
            if(
PlayerData[i][BoatLic] == 10SendClientMessage(iRED"WARNING: Your sailing license will expire in 10 minutes.");
            if(
PlayerData[i][FishLic] == 10SendClientMessage(iRED"WARNING: Your fishing license will expire in 10 minutes.");
            if(
PlayerData[i][GunLic] == 10SendClientMessage(iRED"WARNING: Your weapon license will expire in 10 minutes.");
            if(
PlayerData[i][MatsLic] == 10SendClientMessage(iRED"WARNING: Your materials license will expire in 10 minutes.");
            
            
mysql_format(SQLstr128"UPDATE `users` SET `CarLic`='%d' WHERE `id`='%d' LIMIT 1",PlayerData[i][CarLic], PlayerData[i][ID]);
            
mysql_tquery(SQLstr"""");
            
mysql_format(SQLstr128,"UPDATE `users` SET `FlyLic`='%d' WHERE `id`='%d' LIMIT 1",PlayerData[i][FlyLic], PlayerData[i][ID]);
            
mysql_tquery(SQLstr"""");
            
mysql_format(SQLstr128,"UPDATE `users` SET `BoatLic`='%d' WHERE `ID`='%d' LIMIT 1",PlayerData[i][BoatLic], PlayerData[i][ID]);
            
mysql_tquery(SQLstr"""");
            
mysql_format(SQLstr128,"UPDATE `users` SET `FishLic`='%d' WHERE `ID`='%d' LIMIT 1",PlayerData[i][FishLic], PlayerData[i][ID]);
            
mysql_tquery(SQLstr"""");
            
mysql_format(SQLstr128,"UPDATE `users` SET `GunLic`='%d' WHERE `ID`='%d' LIMIT 1",PlayerData[i][GunLic], PlayerData[i][ID]);
            
mysql_tquery(SQLstr"""");
            
mysql_format(SQLstr128,"UPDATE `users` SET `MatsLic`='%d' WHERE `ID`='%d' LIMIT 1",PlayerData[i][MatsLic], PlayerData[i][ID]);
            
mysql_tquery(SQLstr"""");
            
            new 
XPneed GetXPPoints(i);
            if(
Allowed[i] == 0)
            {
                
format(string100"%d / %d XP"PlayerData[i][Exp], XPneed);
                
PlayerTextDrawSetString(iXPRemainstring);
                
format(string100"Time Left: %d min"XPneed-PlayerData[i][Exp]);
                
PlayerTextDrawSetString(iXPTLeftstring);
                
format(string100"Level: %d (%d XP)"PlayerData[i][Level],PlayerData[i][TotalExp]);
                
PlayerTextDrawSetString(iXPTotalstring);
                new 
Float:percent;
                
percent = ((PlayerData[i][Exp] * 100) / XPneed);
                
SetPlayerProgressBarValue(ibarxppercent);
                
HidePlayerProgressBar(ibarxp);
                
ShowPlayerProgressBar(ibarxp);
            }
            
            if(
PlayerData[i][Exp] >= XPneed)
            {
//Level Up
                
PlayerData[i][Level] += 1;
                
SetPlayerScore(iPlayerData[i][Level]);
                new 
money;
                if(
PlayerData[i][Level] < && PlayerData[i][Level] > 0money PlayerData[i][Level] * 1500;
                else 
money PlayerData[i][Level] * 500;
                
GivePlayerCash(imoney);
                
format(stringsizeof(string), "You recieve %d money for level up."money);
                
SendClientMessage(iCOLOR_WHITEstring);
                
PlayerData[i][Exp] = 0;
                
mysql_format(SQLstr256,"UPDATE `users` SET `Exp`='%d',`TotalXP`='%d',`Level`='%d' WHERE `ID`='%d' LIMIT 1",PlayerData[i][Exp],PlayerData[i][TotalExp],PlayerData[i][Level],PlayerData[i][ID]);
                
mysql_tquery(SQLstr"""");
                
            }
        }
        if(
Sleeping[i] == 1)
        {
            
SleepXP[i] += 1;
            if(
SleepXP[i] == 5)
            {
                
PlayerData[i][Exp] += 1;
                
OnExp[i] += 1;
                if(
OnExp[i] >= 120)
                {
                    new 
checks PlayerData[i][Level] * 300;
                    new 
account PlayerData[i][Bank];
                    new 
interest account 300;
                    
PlayerData[i][Bank] += interest;
                    if(
PlayerData[i][FPunish] > 0PlayerData[i][FPunish] -= 1;
                    
SendClientMessage(iCOLOR_WHITE"________ BANK STATEMENT ________");
                    
format(stringsizeof(string), "  Paycheck: $%s"Decimal(checks));
                    
SendClientMessage(iCOLOR_GRAD1string);
                    
format(stringsizeof(string), "  Old Balance: $%s | Interest rate: 0.1%%"Decimal(account));
                    
SendClientMessage(iCOLOR_GRAD1string);
                    
format(stringsizeof(string), "  New balance: $%s"Decimal(PlayerData[i][Bank]));
                    
SendClientMessage(iCOLOR_GRAD5string);
                    
GivePlayerCash(ichecks);
                    
                    
mysql_format(SQLstr,128,"UPDATE `users` SET `Bank`='%d',`FPunish`='%d' WHERE `ID`='%d' LIMIT 1",PlayerData[i][Bank],PlayerData[i][FPunish],PlayerData[i][ID]);
                    
mysql_tquery(SQLstr"""");
                    
                    
OnExp[i] = 0;
                }
                
                
PlayerData[i][TotalExp] += 1;
                
                
mysql_format(SQLstr,128,"UPDATE `users` SET `Exp`='%d',`TotalXP`='%d',`OnExp`='%d' WHERE `ID`='%d' LIMIT 1",PlayerData[i][Exp],PlayerData[i][TotalExp],OnExp[i],PlayerData[i][ID]);
                
mysql_tquery(SQLstr"""");
                
                if(
PlayerData[i][CarLic] > 0PlayerData[i][CarLic] -= 1;
                if(
PlayerData[i][FlyLic] > 0PlayerData[i][FlyLic] -= 1;
                if(
PlayerData[i][BoatLic] > 0PlayerData[i][BoatLic] -= 1;
                if(
PlayerData[i][FishLic] > 0PlayerData[i][FishLic] -= 1;
                if(
PlayerData[i][GunLic] > 0PlayerData[i][GunLic] -= 1;
                if(
PlayerData[i][MatsLic] > 0PlayerData[i][MatsLic] -= 1;
                if(
PlayerData[i][CarLic] == 10SendClientMessage(iRED"WARNING: Your driving license will expire in 10 minutes.");
                if(
PlayerData[i][FlyLic] == 10SendClientMessage(iRED"WARNING: Your flying license will expire in 10 minutes.");
                if(
PlayerData[i][BoatLic] == 10SendClientMessage(iRED"WARNING: Your sailing license will expire in 10 minutes.");
                if(
PlayerData[i][FishLic] == 10SendClientMessage(iRED"WARNING: Your fishing license will expire in 10 minutes.");
                if(
PlayerData[i][GunLic] == 10SendClientMessage(iRED"WARNING: Your weapon license will expire in 10 minutes.");
                if(
PlayerData[i][MatsLic] == 10SendClientMessage(iRED"WARNING: Your materials license will expire in 10 minutes.");
                
                
mysql_format(SQLstr128"UPDATE `users` SET `CarLic`='%d' WHERE `id`='%d' LIMIT 1",PlayerData[i][CarLic], PlayerData[i][ID]);
                
mysql_tquery(SQLstr"""");
                
mysql_format(SQLstr128,"UPDATE `users` SET `FlyLic`='%d' WHERE `id`='%d' LIMIT 1",PlayerData[i][FlyLic], PlayerData[i][ID]);
                
mysql_tquery(SQLstr"""");
                
mysql_format(SQLstr128,"UPDATE `users` SET `BoatLic`='%d' WHERE `ID`='%d' LIMIT 1",PlayerData[i][BoatLic], PlayerData[i][ID]);
                
mysql_tquery(SQLstr"""");
                
mysql_format(SQLstr128,"UPDATE `users` SET `FishLic`='%d' WHERE `ID`='%d' LIMIT 1",PlayerData[i][FishLic], PlayerData[i][ID]);
                
mysql_tquery(SQLstr"""");
                
mysql_format(SQLstr128,"UPDATE `users` SET `GunLic`='%d' WHERE `ID`='%d' LIMIT 1",PlayerData[i][GunLic], PlayerData[i][ID]);
                
mysql_tquery(SQLstr"""");
                
mysql_format(SQLstr128,"UPDATE `users` SET `MatsLic`='%d' WHERE `ID`='%d' LIMIT 1",PlayerData[i][MatsLic], PlayerData[i][ID]);
                
mysql_tquery(SQLstr"""");
                
                new 
XPneed GetXPPoints(i);
                if(
Allowed[i] == 0)
                {
                    
format(string100"%d / %d XP"PlayerData[i][Exp], XPneed);
                    
PlayerTextDrawSetString(iXPRemainstring);
                    
format(string100"Time Left: %d min"XPneed-PlayerData[i][Exp]);
                    
PlayerTextDrawSetString(iXPTLeftstring);
                    
format(string100"Level: %d (%d XP)"PlayerData[i][Level],PlayerData[i][TotalExp]);
                    
PlayerTextDrawSetString(iXPTotalstring);
                    new 
Float:percent;
                    
percent = ((PlayerData[i][Exp] * 100) / XPneed);
                    
SetPlayerProgressBarValue(ibarxppercent);
                    
HidePlayerProgressBar(ibarxp);
                    
ShowPlayerProgressBar(ibarxp);
                }
                
                if(
PlayerData[i][Exp] >= XPneed)
                {
//Level Up
                    
PlayerData[i][Level] += 1;
                    
SetPlayerScore(iPlayerData[i][Level]);
                    new 
money;
                    if(
PlayerData[i][Level] < && PlayerData[i][Level] > 0money PlayerData[i][Level] * 1500;
                    else 
money PlayerData[i][Level] * 500;
                    
GivePlayerCash(imoney);
                    
format(stringsizeof(string), "You recieve %d money for level up."money);
                    
SendClientMessage(iCOLOR_WHITEstring);
                    
PlayerData[i][Exp] = 0;
                    
mysql_format(SQLstr256,"UPDATE `users` SET `Exp`='%d',`TotalXP`='%d',`Level`='%d' WHERE `ID`='%d' LIMIT 1",PlayerData[i][Exp],PlayerData[i][TotalExp],PlayerData[i][Level],PlayerData[i][ID]);
                    
mysql_tquery(SQLstr"""");
                    
                }
                
SleepXP[i] = 0;
            }
        }
    }

Reply


Messages In This Thread
Timer problem - by PepsiCola23 - 22.07.2015, 20:33
Re: Timer problem - by xVIP3Rx - 22.07.2015, 20:46
Re: Timer problem - by PepsiCola23 - 22.07.2015, 20:56
Re: Timer problem - by PepsiCola23 - 23.07.2015, 12:45
Re: Timer problem - by notime - 23.07.2015, 13:02
AW: Timer problem - by Mencent - 23.07.2015, 13:13
Re: Timer problem - by PepsiCola23 - 23.07.2015, 13:35
AW: Timer problem - by Mencent - 23.07.2015, 13:38
Re: Timer problem - by PepsiCola23 - 23.07.2015, 13:50
AW: Timer problem - by Mencent - 23.07.2015, 13:54

Forum Jump:


Users browsing this thread: 2 Guest(s)