help please reguarding timers
#1

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
Reply
#2

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$");
            }
        }
    }
}
Reply
#3

Thanks alot man
Reply
#4

one more thing where dose it end the timers or do i not need to ?
Reply
#5

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).
Reply
#6

ok thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)