help please reguarding timers -
[SF]RobMob - 07.02.2010
i some timers in my gm for my jobs that gives the players money but when i get 50 players on my server and alot of them are using the jobs and when every one uses jobs i get msgs from server ffs to optimise my gm using to much cpu whats the best way to put theese timers in my gm this is how they are in now or can i use one timer for all jobs?
new TaxiCash;
new FireCash;
new MedicCash;
new PoliceCash;
new ServiceCash;
forward TaxiCash();
forward FireCash();
forward MedicCash();
forward PoliceCash();
forward ServiceCash();
public OnGameModeInit()
{
fireCash = SetTimer("FireCash", 60000, 1);
medicCash = SetTimer("MedicCash", 60000, 1);
taxiCash = SetTimer("TaxiCash", 60000, 1);
policeCash = SetTimer("PoliceCash", 60000, 1);
serviseCash = SetTimer("ServiceCash", 60000, 1);
SetTimer("ServerPoints", 1000, true);
SetTimer("NewsUpdate", 500000, true);
public OnGameModeExit()
{
KillTimer(fireCash);
KillTimer(medicCash);
KillTimer(taxiCash);
KillTimer(policeCash);
KillTimer(serviseCash);
return 1;
}
public TaxiCash()
{
for(new i=0; i<MAX_PLAYERS; i++)
{
if(gTeam[i] == TEAM_TAXI)
{
GivePlayerMoney(i, 1000);
SendClientMessage(i, 0xFFFF00AA, "[JOB]: Your earning: 1000$");
}
}
}
public PoliceCash()
{
for(new i=0; i<MAX_PLAYERS; i++)
{
if(gTeam[i] == TEAM_POLICE)
{
GivePlayerMoney(i, 1000);
SendClientMessage(i, 0xFFFF00AA, "[JOB]: Your earning: 1000$");
}
}
}
public ServiseCash()
{
for(new i=0; i<MAX_PLAYERS; i++)
{
if(gTeam[i] == TEAM_SERVISE)
{
GivePlayerMoney(i, 1000);
SendClientMessage(i, 0xFFFF00AA, "[JOB]: Your earning: 1000$");
}
}
}
you get the idea
Re: help please reguarding timers -
MadeMan - 07.02.2010
Yes, you can put them all in 1 timer
pawn Код:
public Payment()
{
for(new i=0; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(gTeam[i] == TEAM_TAXI)
{
GivePlayerMoney(i, 1000);
SendClientMessage(i, 0xFFFF00AA, "[JOB]: Your earning: 1000$");
}
else if(gTeam[i] == TEAM_POLICE)
{
GivePlayerMoney(i, 1000);
SendClientMessage(i, 0xFFFF00AA, "[JOB]: Your earning: 1000$");
}
else if(gTeam[i] == TEAM_SERVISE)
{
GivePlayerMoney(i, 1000);
SendClientMessage(i, 0xFFFF00AA, "[JOB]: Your earning: 1000$");
}
}
}
}
Re: help please reguarding timers -
[SF]RobMob - 07.02.2010
Thanks alot man
Re: help please reguarding timers -
[SF]RobMob - 07.02.2010
one more thing where dose it end the timers or do i not need to ?
Re: help please reguarding timers -
Calgon - 07.02.2010
You don't need to. People add the KillTimer function to OnGameModeExit to avoid the "function not in use" warning (or whatever error it throws).
Re: help please reguarding timers -
[SF]RobMob - 07.02.2010
ok thanks