22.07.2015, 20:33
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
then the killtimer at ongamemodexit.
This is the function
look just at the exp thing
The problem is,its not working,1 minute passes,but exp is the same.
ongamemodeinit i have
PHP код:
usetimer = SetTimer("UsedTimer", 60000, 1);
This is the function
look just at the exp thing
PHP код:
function UsedTimer()
{
new str[256], string[128];
for(new i = 1; i < sizeof(Turfs); i++)
{
if(WarInfo[i][wTime] > 0)
{
WarInfo[i][wTime] -= 1;
new attackers = WarInfo[i][wAttacker];
new defenders = WarInfo[i][wFaction];
foreach(Player, j)
{
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(Player, j)
{
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(j, TEAM_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(j, TEAM_AZTECAS_COLOR,string);
}
}
War[attackers] = 0;
War[defenders] = 0;
if(atscore >= defscore)
winner = 1;
if(defscore > atscore)
winner = 2;
foreach(Player, j)
{
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(j, TEAM_AZTECAS_COLOR,string);
new score = WarScore[j][i];
format(string,sizeof(string),"Your score was: %i (%i deaths)", score, WarDeaths[j][i]);
SendClientMessage(j, TEAM_AZTECAS_COLOR,string);
TurfInfo[i][zOwned] = WarInfo[i][wAttacker];
mysql_format(SQL, str,256,"UPDATE `turfs` SET `Owned`='%d' WHERE `ID`='%d'",WarInfo[i][wAttacker],i);
mysql_tquery(SQL, str, "", "");
//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(j, TEAM_AZTECAS_COLOR,string);
new score = WarScore[j][i];
format(string,sizeof(string),"Your score was: %i (%i deaths)", score, WarDeaths[j][i]);
SendClientMessage(j, TEAM_AZTECAS_COLOR,string);
}
WarScore[j][i] = 0;
WarDeaths[j][i] = 0;
}
GangZoneHideForPlayer(j,i);
if(TurfInfo[i][zOwned] == 2)
{
GangZoneShowForPlayer(j, Turfs[i], TurfColorGrove);
}
if(TurfInfo[i][zOwned] == 3)
{
GangZoneShowForPlayer(j, Turfs[i], TurfColorGSW);
}
if(TurfInfo[i][zOwned] == 4)
{
GangZoneShowForPlayer(j, Turfs[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(string, sizeof(string), "withdraw %d money (WAR).", WarInfo[i][wPrice]);
SafeboxLog(defenders,-1,string);
format(string, sizeof(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(string, sizeof(string), "withdraw %d money (WAR).", WarInfo[i][wPrice]);
SafeboxLog(attackers,-1,string);
format(string, sizeof(string), "deposit %d money (WAR).", WarInfo[i][wPrice]);
SafeboxLog(defenders,-1,string);
}
mysql_format(SQL, str,128,"UPDATE `safeboxs` SET `Money`='%d' WHERE `ID`='%d'",SafeBox[attackers][sbMoney], attackers);
mysql_tquery(SQL, str, "", "");
mysql_format(SQL, str,128,"UPDATE `safeboxs` SET `Money`='%d' WHERE `ID`='%d'",SafeBox[defenders][sbMoney], defenders);
mysql_tquery(SQL, str, "", "");
}
}
}
new hours, minutes, year, month, day;
new datestr[128], timestr[32];
gettime(hours, minutes);
getdate(year, month, day);
format(datestr,128,"%02d.%02d.%d", day, month, year);
format(timestr,32,"%02d:%02d",hours,minutes);
TextDrawSetString(txtTimeDisp,timestr);
TextDrawSetString(txtDateDisp,datestr);
if(minutes == 0 || minutes == 30)
{
RandomEvent();
SetWorldTime(hours);
}
foreach(Player, i)
{
new Float:health;
GetPlayerHealth(i, health);
SetPlayerHealth(i, health-1.0);
if(PlayerData[i][TrackLose] >= 0)
{
if(PlayerData[i][WantedLevel] == 0)
{
PlayerData[i][TrackLose] = -1;
}
else
{
PlayerData[i][TrackLose] -= 1;
mysql_format(SQL, str,128,"UPDATE `users` SET `TrackLose`='%d' WHERE `ID`='%d' LIMIT 1",PlayerData[i][TrackLose],PlayerData[i][ID]);
mysql_tquery(SQL, str, "", "");
}
if(PlayerData[i][TrackLose] == 0)
{
PlayerData[i][WantedLevel] -= 1;
SetPlayerWantedLevel(i,PlayerData[i][WantedLevel]);
mysql_format(SQL, str,128,"UPDATE `users` SET `WantedLevel`='%d' WHERE `ID`='%d' LIMIT 1",PlayerData[i][WantedLevel],PlayerData[i][ID]);
mysql_tquery(SQL, str, "", "");
SendClientMessage(i, COLOR_WHITE,"{5181EE}Wanted: {FFFFFF}You lose 1 wanted level.");
format(string, sizeof(string), "HQ: Suspect %s lose 1 wanted level, current wanted level: %d.", PlayerData[i][Name],PlayerData[i][WantedLevel]);
SendRadioMessage(1, 0x3350FFFF, string);
if(PlayerData[i][WantedLevel] == 0)
{
SendClientMessage(i, COLOR_WHITE,"{5181EE}Wanted: {FFFFFF}You lose all stars.");
format(string, sizeof(string), "HQ: Suspect %s losed all wanted levels.", PlayerData[i][Name]);
SendRadioMessage(1, 0x3350FFFF, string);
PlayerData[i][MDC] = 0;
}
else
{
PlayerData[i][TrackLose] = 30;
}
}
}
if(IsPlayerPaused(i) == false && PlayerData[i][IsLoggedIn] == true && PlayerAFK[i] == 0 && 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] > 0) PlayerData[i][FPunish] -= 1;
SendClientMessage(i, COLOR_WHITE, "________ BANK STATEMENT ________");
format(string, sizeof(string), " Paycheck: $%s", Decimal(checks));
SendClientMessage(i, COLOR_GRAD1, string);
format(string, sizeof(string), " Old Balance: $%s | Interest rate: 0.1%%", Decimal(account));
SendClientMessage(i, COLOR_GRAD1, string);
format(string, sizeof(string), " New balance: $%s", Decimal(PlayerData[i][Bank]));
SendClientMessage(i, COLOR_GRAD5, string);
GivePlayerCash(i, checks);
mysql_format(SQL, str,128,"UPDATE `users` SET `Bank`='%d',`FPunish`='%d' WHERE `ID`='%d' LIMIT 1",PlayerData[i][Bank],PlayerData[i][FPunish],PlayerData[i][ID]);
mysql_tquery(SQL, str, "", "");
OnExp[i] = 0;
}
PlayerData[i][TotalExp] += 1;
mysql_format(SQL, str,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(SQL, str, "", "");
if(PlayerData[i][CarLic] > 0) PlayerData[i][CarLic] -= 1;
if(PlayerData[i][FlyLic] > 0) PlayerData[i][FlyLic] -= 1;
if(PlayerData[i][BoatLic] > 0) PlayerData[i][BoatLic] -= 1;
if(PlayerData[i][FishLic] > 0) PlayerData[i][FishLic] -= 1;
if(PlayerData[i][GunLic] > 0) PlayerData[i][GunLic] -= 1;
if(PlayerData[i][MatsLic] > 0) PlayerData[i][MatsLic] -= 1;
if(PlayerData[i][CarLic] == 10) SendClientMessage(i, RED, "WARNING: Your driving license will expire in 10 minutes.");
if(PlayerData[i][FlyLic] == 10) SendClientMessage(i, RED, "WARNING: Your flying license will expire in 10 minutes.");
if(PlayerData[i][BoatLic] == 10) SendClientMessage(i, RED, "WARNING: Your sailing license will expire in 10 minutes.");
if(PlayerData[i][FishLic] == 10) SendClientMessage(i, RED, "WARNING: Your fishing license will expire in 10 minutes.");
if(PlayerData[i][GunLic] == 10) SendClientMessage(i, RED, "WARNING: Your weapon license will expire in 10 minutes.");
if(PlayerData[i][MatsLic] == 10) SendClientMessage(i, RED, "WARNING: Your materials license will expire in 10 minutes.");
mysql_format(SQL, str, 128, "UPDATE `users` SET `CarLic`='%d' WHERE `id`='%d' LIMIT 1",PlayerData[i][CarLic], PlayerData[i][ID]);
mysql_tquery(SQL, str, "", "");
mysql_format(SQL, str, 128,"UPDATE `users` SET `FlyLic`='%d' WHERE `id`='%d' LIMIT 1",PlayerData[i][FlyLic], PlayerData[i][ID]);
mysql_tquery(SQL, str, "", "");
mysql_format(SQL, str, 128,"UPDATE `users` SET `BoatLic`='%d' WHERE `ID`='%d' LIMIT 1",PlayerData[i][BoatLic], PlayerData[i][ID]);
mysql_tquery(SQL, str, "", "");
mysql_format(SQL, str, 128,"UPDATE `users` SET `FishLic`='%d' WHERE `ID`='%d' LIMIT 1",PlayerData[i][FishLic], PlayerData[i][ID]);
mysql_tquery(SQL, str, "", "");
mysql_format(SQL, str, 128,"UPDATE `users` SET `GunLic`='%d' WHERE `ID`='%d' LIMIT 1",PlayerData[i][GunLic], PlayerData[i][ID]);
mysql_tquery(SQL, str, "", "");
mysql_format(SQL, str, 128,"UPDATE `users` SET `MatsLic`='%d' WHERE `ID`='%d' LIMIT 1",PlayerData[i][MatsLic], PlayerData[i][ID]);
mysql_tquery(SQL, str, "", "");
new XPneed = GetXPPoints(i);
if(Allowed[i] == 0)
{
format(string, 100, "%d / %d XP", PlayerData[i][Exp], XPneed);
PlayerTextDrawSetString(i, XPRemain, string);
format(string, 100, "Time Left: %d min", XPneed-PlayerData[i][Exp]);
PlayerTextDrawSetString(i, XPTLeft, string);
format(string, 100, "Level: %d (%d XP)", PlayerData[i][Level],PlayerData[i][TotalExp]);
PlayerTextDrawSetString(i, XPTotal, string);
new Float:percent;
percent = ((PlayerData[i][Exp] * 100) / XPneed);
SetPlayerProgressBarValue(i, barxp, percent);
HidePlayerProgressBar(i, barxp);
ShowPlayerProgressBar(i, barxp);
}
if(PlayerData[i][Exp] >= XPneed)
{//Level Up
PlayerData[i][Level] += 1;
SetPlayerScore(i, PlayerData[i][Level]);
new money;
if(PlayerData[i][Level] < 8 && PlayerData[i][Level] > 0) money = PlayerData[i][Level] * 1500;
else money = PlayerData[i][Level] * 500;
GivePlayerCash(i, money);
format(string, sizeof(string), "You recieve %d money for level up.", money);
SendClientMessage(i, COLOR_WHITE, string);
PlayerData[i][Exp] = 0;
mysql_format(SQL, str, 256,"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(SQL, str, "", "");
}
}
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] > 0) PlayerData[i][FPunish] -= 1;
SendClientMessage(i, COLOR_WHITE, "________ BANK STATEMENT ________");
format(string, sizeof(string), " Paycheck: $%s", Decimal(checks));
SendClientMessage(i, COLOR_GRAD1, string);
format(string, sizeof(string), " Old Balance: $%s | Interest rate: 0.1%%", Decimal(account));
SendClientMessage(i, COLOR_GRAD1, string);
format(string, sizeof(string), " New balance: $%s", Decimal(PlayerData[i][Bank]));
SendClientMessage(i, COLOR_GRAD5, string);
GivePlayerCash(i, checks);
mysql_format(SQL, str,128,"UPDATE `users` SET `Bank`='%d',`FPunish`='%d' WHERE `ID`='%d' LIMIT 1",PlayerData[i][Bank],PlayerData[i][FPunish],PlayerData[i][ID]);
mysql_tquery(SQL, str, "", "");
OnExp[i] = 0;
}
PlayerData[i][TotalExp] += 1;
mysql_format(SQL, str,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(SQL, str, "", "");
if(PlayerData[i][CarLic] > 0) PlayerData[i][CarLic] -= 1;
if(PlayerData[i][FlyLic] > 0) PlayerData[i][FlyLic] -= 1;
if(PlayerData[i][BoatLic] > 0) PlayerData[i][BoatLic] -= 1;
if(PlayerData[i][FishLic] > 0) PlayerData[i][FishLic] -= 1;
if(PlayerData[i][GunLic] > 0) PlayerData[i][GunLic] -= 1;
if(PlayerData[i][MatsLic] > 0) PlayerData[i][MatsLic] -= 1;
if(PlayerData[i][CarLic] == 10) SendClientMessage(i, RED, "WARNING: Your driving license will expire in 10 minutes.");
if(PlayerData[i][FlyLic] == 10) SendClientMessage(i, RED, "WARNING: Your flying license will expire in 10 minutes.");
if(PlayerData[i][BoatLic] == 10) SendClientMessage(i, RED, "WARNING: Your sailing license will expire in 10 minutes.");
if(PlayerData[i][FishLic] == 10) SendClientMessage(i, RED, "WARNING: Your fishing license will expire in 10 minutes.");
if(PlayerData[i][GunLic] == 10) SendClientMessage(i, RED, "WARNING: Your weapon license will expire in 10 minutes.");
if(PlayerData[i][MatsLic] == 10) SendClientMessage(i, RED, "WARNING: Your materials license will expire in 10 minutes.");
mysql_format(SQL, str, 128, "UPDATE `users` SET `CarLic`='%d' WHERE `id`='%d' LIMIT 1",PlayerData[i][CarLic], PlayerData[i][ID]);
mysql_tquery(SQL, str, "", "");
mysql_format(SQL, str, 128,"UPDATE `users` SET `FlyLic`='%d' WHERE `id`='%d' LIMIT 1",PlayerData[i][FlyLic], PlayerData[i][ID]);
mysql_tquery(SQL, str, "", "");
mysql_format(SQL, str, 128,"UPDATE `users` SET `BoatLic`='%d' WHERE `ID`='%d' LIMIT 1",PlayerData[i][BoatLic], PlayerData[i][ID]);
mysql_tquery(SQL, str, "", "");
mysql_format(SQL, str, 128,"UPDATE `users` SET `FishLic`='%d' WHERE `ID`='%d' LIMIT 1",PlayerData[i][FishLic], PlayerData[i][ID]);
mysql_tquery(SQL, str, "", "");
mysql_format(SQL, str, 128,"UPDATE `users` SET `GunLic`='%d' WHERE `ID`='%d' LIMIT 1",PlayerData[i][GunLic], PlayerData[i][ID]);
mysql_tquery(SQL, str, "", "");
mysql_format(SQL, str, 128,"UPDATE `users` SET `MatsLic`='%d' WHERE `ID`='%d' LIMIT 1",PlayerData[i][MatsLic], PlayerData[i][ID]);
mysql_tquery(SQL, str, "", "");
new XPneed = GetXPPoints(i);
if(Allowed[i] == 0)
{
format(string, 100, "%d / %d XP", PlayerData[i][Exp], XPneed);
PlayerTextDrawSetString(i, XPRemain, string);
format(string, 100, "Time Left: %d min", XPneed-PlayerData[i][Exp]);
PlayerTextDrawSetString(i, XPTLeft, string);
format(string, 100, "Level: %d (%d XP)", PlayerData[i][Level],PlayerData[i][TotalExp]);
PlayerTextDrawSetString(i, XPTotal, string);
new Float:percent;
percent = ((PlayerData[i][Exp] * 100) / XPneed);
SetPlayerProgressBarValue(i, barxp, percent);
HidePlayerProgressBar(i, barxp);
ShowPlayerProgressBar(i, barxp);
}
if(PlayerData[i][Exp] >= XPneed)
{//Level Up
PlayerData[i][Level] += 1;
SetPlayerScore(i, PlayerData[i][Level]);
new money;
if(PlayerData[i][Level] < 8 && PlayerData[i][Level] > 0) money = PlayerData[i][Level] * 1500;
else money = PlayerData[i][Level] * 500;
GivePlayerCash(i, money);
format(string, sizeof(string), "You recieve %d money for level up.", money);
SendClientMessage(i, COLOR_WHITE, string);
PlayerData[i][Exp] = 0;
mysql_format(SQL, str, 256,"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(SQL, str, "", "");
}
SleepXP[i] = 0;
}
}
}
}