SA-MP Forums Archive
Scripting Paycheck 0.3e Help - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Scripting Paycheck 0.3e Help (/showthread.php?tid=370464)



Scripting Paycheck 0.3e Help - Amora187 - 20.08.2012

So how can i script the Paycheck? i was trying to make a timer but it makes an error thats why i need help from you to help me how to script the Paycheck in 0.3e and yes i scripted the time but when i added it in timer it bugs then i deleted it till i needed help so can you please help me guys?


Re: Scripting Paycheck 0.3e Help - Cjgogo - 20.08.2012

Obviusly you cannot use timers,but it's not your fault,you're a beginner,therefor,here it goes:
pawn Код:
new PayCheck[MAX_PLAYERS];
forward GivePlayerCheck(playerid);

public OnPlayerConnect(playerid)
{
    PayCheck[playerid]=SetTimerEx("GivePlayerCheck",600000,true,"i",playerid);//repeats every 10 minutes
 return 1;
}

public OnPlayerDisconnect(playerid)
{
    KillTimer(PayCheck[playerid]);
  return 1;
}

public GivePlayerCheck(playerid)
{
    GivePlayerMoney(playerid,5000);
 return 1;
}



Re: Scripting Paycheck 0.3e Help - milanosie - 20.08.2012

Quote:
Originally Posted by Cjgogo
Посмотреть сообщение
Obviusly you cannot use timers,but it's not your fault,you're a beginner,therefor,here it goes:
pawn Код:
new PayCheck[MAX_PLAYERS];
forward GivePlayerCheck(playerid);

public OnPlayerConnect(playerid)
{
    PayCheck[playerid]=SetTimerEx("GivePlayerCheck",600000,true,"i",playerid);//repeats every 10 minutes
 return 1;
}

public OnPlayerDisconnect(playerid)
{
    KillTimer(PayCheck[playerid]);
  return 1;
}

public GivePlayerCheck(playerid)
{
    GivePlayerMoney(playerid,5000);
 return 1;
}
Ofcourse you can use timers!

This is my paycheck:
pawn Код:
OnGamemodeInit()
{
    SetTimer("MinuteUpdate", 60000, true);
}

public MinuteUpdate()
{
    new hour,minute,second;
    gettime(hour,minute,second);
    if(hour != hourding)
    {
        hourding = hour;
        new string[128];
        foreach(Player, q)
        {
            new tax;
            new salary = 500;
            SendClientMessage(q, COLOR_WHITE, "_________________________San Andreas Bank Statement_________________________");
            if(PlayerInfo[q][Vehicle1] != 0) tax = tax + 50;
            if(PlayerInfo[q][Vehicle2] != 0) tax = tax + 55;
            if(PlayerInfo[q][Vehicle3] != 0) tax = tax + 45;
            if(PlayerInfo[q][House] != 0)    tax = tax + 120;
            if(PlayerInfo[q][Job] != 0)      salary = salary + 200;
            if(PlayerInfo[q][Faction] != 0)  salary = salary + (PlayerInfo[q][FactionRank] * 300);
            format(string, sizeof(string), "Tax: $%d" ,tax);
            scm(q, white, string);
            format(string, sizeof(string), "Salary: $%d", salary);
            scm(q, white, string);
            PlayerInfo[q][Bank] = PlayerInfo[q][Bank] - tax;
            PlayerInfo[q][Bank] = PlayerInfo[q][Bank] + salary;
            PlayAudioStreamForPlayer(q, "http://milania91.ninetyone.axc.nl/sounds/MissionComplete.mp3");
            SetPlayerScore(q, GetPlayerScore(q) + 1);
        }
    }
    SetWorldTime(hour);
}
It checks if the previous saved hour (hourding) is NOT equal to the current hour. If this is true then a new hour has just started which means it can give a payday