Payday spamming.
#1

So, I got this problem with my day literally spamming when the timer has loaded. Why does it do that?

pawn Код:
forward payday(playerid);
public payday(playerid)
{
    GivePlayerMoney(playerid, 1000);
    SendClientMessage(playerid, COLOR_GREEN, "_______ BANK OF LOS SANTOS _______ ");
    SendClientMessage(playerid, COLOR_GREEN, "BANK:{FFFFFF} You've received 500$ from the goverment.");
    SendClientMessage(playerid, COLOR_GREEN, "___________________________________");
    GameTextForPlayer(playerid, "~w~PAYDAY, USD 500.", 5000, 4);
    SetTimerEx("payday", 560, true, "i", playerid);
    printf("SERVER: Payday has been executed. :)");
    return 1;
}
pawn Код:
SetTimerEx("payday", 560, true, "i", playerid);
Reply
#2

Fixed it, but now it doesn't even Payday once the player is InGame??
Reply
#3

Create a forloop to check if the player is connected.

PHP код:
forward payday(playerid);
public 
payday(playerid)
{
 for(new 
0MAX_PLAYERSi++)
    {
    if(
IsPlayerConnected(i))// continue;
    
{
    
GivePlayerMoney(i1000);
    
SendClientMessage(iCOLOR_GREEN"_______ BANK OF LOS SANTOS _______ ");
    
SendClientMessage(iCOLOR_GREEN"BANK:{FFFFFF} You've received 500$ from the goverment.");
    
SendClientMessage(iCOLOR_GREEN"___________________________________");
    
GameTextForPlayer(i"~w~PAYDAY, USD 500."50004);
    
SetTimerEx("payday"560true"i"playerid);
    
printf("SERVER: Payday has been executed. :)");
    return 
1;

Try this..
Reply
#4

thanks bro

but im rather new to scripting, can you explain me what does this function?

pawn Код:
for(new i = 0; i < MAX_PLAYERS; i++)
?
Reply
#5

This Should explain everything..
https://sampwiki.blast.hk/wiki/Loops
Reply
#6

I dont think he needs a for loop, as his function is passing playerid into it for the PayDay. However, do look up on for loops, they are a vital part of logical coding in any language.

As for your timer, you're currently setting the interval to 560...that's 560 MILLISECONDS. Not seconds. Sounds to me, that by the time your player has properly connected and logged in, the payday function has already been executed for them.

I don't know how long you want the timer to be before each payday, but for example the following would execute your function every minute.

Код:
SetTimerEx("payday", 1000, true, "i", playerid);
For further information, see: https://sampwiki.blast.hk/wiki/SetTimerEx
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)