Payday not working.
#1

pawn Код:
forward payday(playerid);
public payday(playerid)
{
    new payday;
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
    if(IsPlayerConnected(i))// continue;
    {
   
    if(PlayerInfo[playerid][PayDay] == 1)
    {
    GivePlayerMoney(i, 3500);
    SendClientMessage(i, COLOR_GREEN, "_______ BANK OF LOS SANTOS _______ ");

    SendClientMessage(i, COLOR_GREEN, "BANK:{FFFFFF} You've received 3500$ from the goverment.");
    SendClientMessage(i, COLOR_LIGHTRED, "[ ! ] SERVER: As a new player, with play time: [ 3 ]. You've been given 750$.");

    SendClientMessage(i, COLOR_GREEN, "___________________________________");
    GameTextForPlayer(i, "~w~PAYDAY, USD 750.", 5000, 4);
    PlayerInfo[playerid][PayDay] +=payday;
    }
    if(PlayerInfo[playerid][PayDay] == 2)
    {
    GivePlayerMoney(i, 1500);
    SendClientMessage(i, COLOR_GREEN, "_______ BANK OF LOS SANTOS _______ ");

    SendClientMessage(i, COLOR_GREEN, "BANK:{FFFFFF} You've received 1500$ from the goverment.");
    SendClientMessage(i, COLOR_LIGHTRED, "[ ! ] SERVER: As a new player, with play time: [ 2 ]. You've been given 1500$.");

    SendClientMessage(i, COLOR_GREEN, "___________________________________");
    GameTextForPlayer(i, "~w~PAYDAY, USD 1500.", 5000, 4);
    }
    if(PlayerInfo[playerid][PayDay] == 3)
    {
    GivePlayerMoney(i, 750);
    SendClientMessage(i, COLOR_GREEN, "_______ BANK OF LOS SANTOS _______ ");

    SendClientMessage(i, COLOR_GREEN, "BANK:{FFFFFF} You've received 750$ from the goverment.");
    SendClientMessage(i, COLOR_LIGHTRED, "[ ! ] SERVER: As a new player, with play time: [ 3 ]. You've been given 750$.");

    SendClientMessage(i, COLOR_GREEN, "___________________________________");
    GameTextForPlayer(i, "~w~PAYDAY, USD 750.", 5000, 4);
    }
    if(PlayerInfo[playerid][PayDay] == 4)
    {
    GivePlayerMoney(i, 500);
    SendClientMessage(i, COLOR_GREEN, "_______ BANK OF LOS SANTOS _______ ");
   
    SendClientMessage(i, COLOR_GREEN, "BANK:{FFFFFF} You've received 500$ from the goverment.");
    SendClientMessage(i, COLOR_LIGHTRED, "[ ! ] SERVER: As a normal player, you'll only be given 500$.");
    SendClientMessage(i, COLOR_LIGHTRED, "[ ! ] SERVER: If you wish a raisen paycheck. Check forums donation section.");
   
    SendClientMessage(i, COLOR_GREEN, "___________________________________");
    GameTextForPlayer(i, "~w~PAYDAY, USD 500.", 5000, 4);
    }
    printf("SERVER: Payday has been executed. :)");
    }
    }
    return 1;
}
Okay, so I made this little piece of code, and I wanted to do like new players will get like 3500$ the first payday, and next 1500 and the third 750 and then normal 500$, but its like it doesnt give me anything, not even message, and then server crash or doesnt respond at all.

Any help?
Reply
#2

Set A Timer to update the payment?
Reply
#3

You dont really read what I'm writing? it doesnt give me any money or message at any time
Reply
#4

Could you get crashdetect and give us the content inside the server_log.txt after your server crash?
Reply
#5

It doesn't crash like that. Server is just getting to lag, and not responding, but server is still running.
Reply
#6

Fixed the crash. Now it just doesn't give me the money or messages.
Reply
#7

First, add after pubic payday;
Player[playerid][PayDay]++;
Then it'll work.

Also, add an else statement
Reply
#8

PHP код:
forward payday();
public 
payday()
{ 
Also This..
Reply
#9

Avoid repeating large chunks of almost identical code and use some variables instead. Rewritten:
PHP код:
public payday(playerid)
{
    for(new 
i = 0, j = GetPlayerPoolSize(); i <= j; i++)
    {
        if(!
IsPlayerConnected(i)) 
            continue;
            
        new 
            
money,
            
message[100];
    
        switch(
PlayerInfo[playerid][PayDay])
        {
            case 
1: money = 3500;
            case 
2: money = 1500;
            case 
3: money = 750;
            default: 
money = 500;
        }
        
        
GivePlayerMoney(i, money);
        
SendClientMessage(i, COLOR_GREEN, "_______ BANK OF LOS SANTOS _______ ");
        
        
format(message, sizeof message, "BANK:{FFFFFF} You've received $%d from the goverment.", money);
        
SendClientMessage(i, COLOR_GREEN, message);
        
        if(
PlayerInfo[playerid][PayDay] <= 3)
        {
            
format(message, sizeof message, "[ ! ] SERVER: As a new player, with play time: [ %d ]. You've been given $%d.", PlayerInfo[playerid][PayDay], money);
            
SendClientMessage(i, COLOR_LIGHTRED, message);
        }
        else
        {
            
SendClientMessage(i, COLOR_LIGHTRED, "[ ! ] SERVER: As a normal player, you'll only be given 500$.");
            
SendClientMessage(i, COLOR_LIGHTRED, "[ ! ] SERVER: If you wish a raisen paycheck. Check forums donation section.");
        }
        
        
SendClientMessage(i, COLOR_GREEN, "___________________________________");
        
        
format(message, sizeof message, "~w~PAYDAY, USD %d.", money);
        
GameTextForPlayer(i, message, 5000, 4);
    }
    
printf("SERVER: Payday has been executed. :)");
    return 
1;
} 
And for your sake, I hope you don't still have it in OnPlayerUpdate.
Reply
#10

Quote:
Originally Posted by Vince
Посмотреть сообщение
Avoid repeating large chunks of almost identical code and use some variables instead. Rewritten:
PHP код:
public payday(playerid)
{
    for(new 
i = 0, j = GetPlayerPoolSize(); i <= j; i++)
    {
        if(!
IsPlayerConnected(i)) 
            continue;
            
        new 
            
money,
            
message[100];
    
        switch(
PlayerInfo[playerid][PayDay])
        {
            case 
1: money = 3500;
            case 
2: money = 1500;
            case 
3: money = 750;
            default: 
money = 500;
        }
        
        
GivePlayerMoney(i, money);
        
SendClientMessage(i, COLOR_GREEN, "_______ BANK OF LOS SANTOS _______ ");
        
        
format(message, sizeof message, "BANK:{FFFFFF} You've received $%d from the goverment.", money);
        
SendClientMessage(i, COLOR_GREEN, message);
        
        if(
PlayerInfo[playerid][PayDay] <= 3)
        {
            
format(message, sizeof message, "[ ! ] SERVER: As a new player, with play time: [ %d ]. You've been given $%d.", PlayerInfo[playerid][PayDay], money);
            
SendClientMessage(i, COLOR_LIGHTRED, message);
        }
        else
        {
            
SendClientMessage(i, COLOR_LIGHTRED, "[ ! ] SERVER: As a normal player, you'll only be given 500$.");
            
SendClientMessage(i, COLOR_LIGHTRED, "[ ! ] SERVER: If you wish a raisen paycheck. Check forums donation section.");
        }
        
        
SendClientMessage(i, COLOR_GREEN, "___________________________________");
        
        
format(message, sizeof message, "~w~PAYDAY, USD %d.", money);
        
GameTextForPlayer(i, message, 5000, 4);
    }
    
printf("SERVER: Payday has been executed. :)");
    return 
1;
} 
And for your sake, I hope you don't still have it in OnPlayerUpdate.
I think you have forgot to add Player[playerid][PayDay]++;

And Instead of if(PlayerInfo[playerid][PayDay] <= 3)
you have to use if(PlayerInfo[playerid][PayDay] >= 3)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)