i want fix the paychack RP please
#9

Quote:
Originally Posted by yanir3
Посмотреть сообщение
Use a timer on OnPlayerConnect setting to 1 hour.
Example

PayDay = The public
3600000 = 60 minutes (in milliseconds)
true = makes the timer repeat.
You're kidding me, right? Using that callback for SetTimer is a bad idea. A player connects, the timer is set again, another player connects, the timer is set again, think about it.

pawn Код:
#include <a_samp>

forward PayDay();

#define PAYDAY_INTERVAL 3600000

new PayDayTimer;
new Milliseconds;

public OnGameModeInit()
{
    // stuff
    PayDayTimer = SetTimer("PayDay", PAYDAY_INTERVAL, true);
    Milliseconds = PAYDAY_INTERVAL;
    // stuff
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    if(!strcmp(cmdtext, "/stats", true))
    {
        // some stuff...
        new str[64];
        format(str, sizeof(str), "Your next paycheck will be in %i minutes.",Milliseconds/60000);
        SendClientMessage(playerid, 0xFFFF00FF, str);
        // stuff...
        return 1;
     }
     return 1;
}

public PayDay()
{
    new string[128];
    new account,interest;
    new rent = 0;
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i) && !IsPlayerNPC(i))
        {
            if(PlayerInfo[i][pLevel] > 0)
            {
                if(MoneyMessage[i]==1)
                {
                    new bank = PlayerInfo[i][pAccount];
                    SendClientMessage(i, COLOR_LIGHTRED, "You failed to pay your debt, Jail time.");
                    GameTextForPlayer(i, "~r~Busted!", 2000, 1);
                    SafeSetPlayerInterior(i, 6);
                    SafeSetPlayerPos(i, 264.6288,77.5742,1001.0391);
                    PlayerInfo[i][pJailed] = 1;
                    SafeResetPlayerWeapons(i);
                    SafeResetPlayerMoney(i);
                    SafeGivePlayerMoney(i, 1);
                    WantedPoints[i] = 0;
                    PlayerInfo[i][pAccount] = (bank + DebtMoney[i]);
                    DebtMoney[i] = 0;
                    PlayerInfo[i][pJailTime] = 240;
                    TextDrawShowForPlayer(i, Textdraw1[i]);
                    format(string, sizeof(string), "You are jailed for %d seconds.   Bail: Unable", PlayerInfo[i][pJailTime]);
                    SendClientMessage(i, COLOR_WHITE, string);
                }
                new playername2[MAX_PLAYER_NAME];
                GetPlayerName(i, playername2, sizeof(playername2));
                account = PlayerInfo[i][pAccount];
                new key = PlayerInfo[i][pPhousekey];
                if(key != 9999)
                {
                    rent = HouseInfo[key][hRent];
                    if(strcmp(playername2, HouseInfo[key][hOwner], true) == 0)
                    {
                        rent = 0;
                    }
                    else if(rent > GetPlayerMoney(i))
                    {
                        PlayerInfo[i][pPhousekey] = 9999;
                        SendClientMessage(i, COLOR_WHITE, "You have been evicted.");
                        rent = 0;
                    }
                    HouseInfo[key][hTakings] = HouseInfo[key][hTakings]+rent;
                }
                new tmpintrate;
                if (key != 999 && strcmp(playername2, HouseInfo[key][hOwner], true) == 0)
                {
                    if(PlayerInfo[i][pRegularRank] > 0) { tmpintrate = intrate+4; }
                    else { tmpintrate = intrate+2; }//HouseInfo[key][hLevel]
                }
                else
                {
                    if(PlayerInfo[i][pRegularRank] > 0) { tmpintrate = 3; }
                    else { tmpintrate = 1; }
                }
                if(PlayerInfo[i][pPayDay] >= 5)
                {
                    Tax += TaxValue;//Should work for every player online
                    PlayerInfo[i][pAccount] -= TaxValue;
                    new checks = PlayerInfo[i][pPayCheck] / 5;
                    if(PlayerInfo[i][pRegularRank] > 0)
                    {
                        new bonus = PlayerInfo[i][pPayCheck] / 10;
                        checks += bonus;
                    }
                    new ebill = (PlayerInfo[i][pAccount]/10000)*(PlayerInfo[i][pLevel]);
                    account += checks;
                    if(PlayerInfo[i][pAccount] > 0)
                    {
                        PlayerInfo[i][pAccount] -= ebill;
                        SBizzInfo[4][sbTill] += ebill;
                    }
                    else
                    {
                        ebill = 0;
                    }
                    interest = (PlayerInfo[i][pAccount]/1000)*(tmpintrate);
                    PlayerInfo[i][pExp]++;
                    PlayerPlayMusic(i);
                    PlayerInfo[i][pAccount] = account+interest;
                    SendClientMessage(i, COLOR_GREEN, "|___ BANK STATMENT ___|");
                    format(string, sizeof(string), "  Paycheck: $%d   Tax Money: -$%d", checks, TaxValue);
                    SendClientMessage(i, COLOR_WHITE, string);
                    if(PlayerInfo[i][pPhousekey] != 9999 || PlayerInfo[i][pPbiskey] != 9999)
                    {
                        format(string, sizeof(string), "  Electricity Bill: -$%d", ebill);
                        SendClientMessage(i, COLOR_GRAD1, string);
                    }
                    format(string, sizeof(string), "  Balance: $%d", account - checks);
                    SendClientMessage(i, COLOR_WHITE, string);
                    format(string, sizeof(string), "  Interest Rate: 0.%d percent",tmpintrate);
                    SendClientMessage(i, COLOR_GRAD2, string);
                    format(string, sizeof(string), "  Interest Gained $%d", interest);
                    SendClientMessage(i, COLOR_GRAD3, string);
                    SendClientMessage(i, COLOR_GREEN, "|--------------------------------------|");
                    format(string, sizeof(string), "  New Balance: $%d", PlayerInfo[i][pAccount]);
                    SendClientMessage(i, COLOR_GRAD5, string);
                    format(string, sizeof(string), "  Rent: -$%d", rent);
                    SendClientMessage(i, COLOR_GRAD5, string);
                    format(string, sizeof(string), "~y~PayDay~n~~w~Check paid into your account");
                    GameTextForPlayer(i, string, 5000, 1);
                    rent = 0;
                    PlayerInfo[i][pPayDay] = 0;
                    PlayerInfo[i][pPayCheck] = 0;
                    if(FarmerVar[i] == 0)
                    {
                        FarmerPickup[i][0] = 0;
                    }
                    if(DrugFarmerVar[i] == 0)
                    {
                        DrugFarmerPickup[i][0] = 0;
                    }
                    if(SmugglerWork[i] == 0)
                    {
                        PayDaySecure[i] = 0;
                    }
                    if(PlayerInfo[i][pRegularRank] > 0)
                    {
                        PlayerInfo[i][pPayDayHad] += 1;
                        if(PlayerInfo[i][pPayDayHad] >= 5)
                        {
                            PlayerInfo[i][pExp]++;
                            PlayerInfo[i][pPayDayHad] = 0;
                        }
                    }
                }
                else
                {
                    SendClientMessage(i, COLOR_WHITE, "* You haven't played long enough to obtain a PayDay.");
                }
            }
        }
    }
    Milliseconds = PAYDAY_INTERVAL;
    SaveAccounts();
    new rand = random(2500); rand += 1245;
    Jackpot += rand;
    SaveStuff();
    SaveAnticheat();
    format(string, sizeof(string), "Lottery News: Our New Jackpot has been increased to $%d.", Jackpot);
    OOCOff(COLOR_WHITE, string);
    return 1;
}
Reply


Messages In This Thread
i want fix the paychack RP please - by Vlad_Riabov - 11.01.2011, 15:36
Re: i want fix the paychack RP please - by Vlad_Riabov - 11.01.2011, 20:49
Re: i want fix the paychack RP please - by _rAped - 11.01.2011, 21:05
Re: i want fix the paychack RP please - by Vlad_Riabov - 11.01.2011, 22:59
Re: i want fix the paychack RP please - by Vlad_Riabov - 12.01.2011, 08:19
Re: i want fix the paychack RP please - by Macluawn - 12.01.2011, 08:35
Re: i want fix the paychack RP please - by Vlad_Riabov - 12.01.2011, 12:57
Re: i want fix the paychack RP please - by yanir3 - 12.01.2011, 14:04
Re: i want fix the paychack RP please - by California - 12.01.2011, 14:19
Re: i want fix the paychack RP please - by Vlad_Riabov - 12.01.2011, 14:59

Forum Jump:


Users browsing this thread: 2 Guest(s)