Hello There, Guest! Login or Register


Public function, taxupdater
#10
Code:
[quote='The_Zodiac link' pid='7834' dateline='1208911845']
change it for:
[code]forward TaxUpdater(playerid);
and
public TaxUpdater(playerid)
[/code][/quote]
There is no need to declare a function with the parameters included.

First, indent you code corectly D:
Code:
public TaxUpdater(playerid)
{
    for(new i=0;i<MAX_PLAYERS;i++)
    {
    SetTimerEx("TaxUpdater", 180000, 1,"i",i);
// u closed the for() loop where u defined 'i' !!!     }
    
        if(GetPlayerMoney(i) > 3000000)
        {
            GivePlayerMoney(i,-100000);
            SendClientMessage(i, COLOR_GREEN,"You payed 100000 tax.");
        }
}

}

But, that code will cause a huge CPU load :o

This is better:

Code:
top:

forward TaxUpdater();

Ongameinit:

SetTimerEx("TaxUpdater", 180000, 1,"i",i);

function:

public TaxUpdater(playerid)
{
    for(new i=0;i<MAX_PLAYERS;i++)
    {
        if(IsPlayerConnected(i) == 1)
            {
        if(GetPlayerMoney(i) > 3000000)
                {
        GivePlayerMoney(i,-100000);
        SendClientMessage(i, COLOR_GREEN,"You payed 100000 tax.");
        }
           }
    }
}

just a tip: you can check if a timer is running by simple adding a 'debug message', just a simple SendClientMessageToAll(white, "Time activated"); to the function it should trigger.


-oost 8)
Reply


Messages In This Thread
Public function, taxupdater - by Dimplex - 04-22-2008, 04:02 PM
Re: Public function, taxupdater - by Jay - 04-22-2008, 04:58 PM
Re: Public function, taxupdater - by Dimplex - 04-22-2008, 05:28 PM
Re: Public function, taxupdater - by Xanland - 04-22-2008, 05:54 PM
Re: Public function, taxupdater - by Jay - 04-22-2008, 08:54 PM
Re: Public function, taxupdater - by The_Zodiac - 04-23-2008, 01:50 AM
Re: Public function, taxupdater - by Jay - 04-23-2008, 04:57 PM
Re: Public function, taxupdater - by Smoke - 04-24-2008, 11:03 AM
Re: Public function, taxupdater - by Dimplex - 04-24-2008, 02:19 PM
Re: Public function, taxupdater - by Joeri - 04-24-2008, 03:20 PM