Paycheck Problem
#1

This code should on every hour on the MinuteTimer it will execute the SyncTime function will then execute the Payday() function on the 00 hour. For some reason it does it randomly in between the hour and on top of that it doesn't give every single person there paycheck. What I'm actually thinking is that the server does this function for the player every hour. Does anyone have any idea as to what is going on here?
PHP код:
task MinuteTimer[60000]()
{
    new 
string[128], cMinutecHour;
     
//, iv = INVALID_PLAYER_ID; For fuel system
    
    
foreach(new playeridPlayer)
    {
        
MinutesConnected[playerid]++;
        
SyncTime();
    }
}
forward SyncTime();
public 
SyncTime()
{
    new
        
string[64],
        
tmphour,
        
tmpminute,
        
tmpsecond;
    
gettime(tmphourtmpminutetmpsecond);
    
FixHour(tmphour);
    
tmphour shifthour;
    if((
tmphour ghour) || (tmphour == && ghour == 23))
    {
        
format(stringsizeof(string), "The time is now %d:00.",tmphour);
        
SendClientMessageToAll(COLOR_WHITE,string);
        
ghour tmphour;
        
Payday();
    }
}
Payday()
{
    foreach(new 
playeridPlayer)
    {
        new 
moneyGivenPhoneBillFloat:InterestRateInterestMinutesTabbedMinutesRealPlayerLeveltaxamountexpextra 1;
         if(
MinutesConnected[playerid] < MINUTES_FOR_PAYDAY)
           {
             return 
SendClientMessage(playeridCOLOR_GRAD3"You have not played long enough to receive a paycheck.");
        }
        
printf("Tab Time3: %d"totalTimeTab[playerid]);
        
printf("Minutes Time3: %d"MinutesConnected[playerid]);
        
printf("PlayerID3: %d"playerid);
        
//Interest Rates
        
if(PlayerInfo[playerid][pVIP] == 0)
        {
            
InterestRate 0.01;
        }
        else if(
PlayerInfo[playerid][pVIP] == 1)
        {
            
InterestRate 0.015;
        }
        else if(
PlayerInfo[playerid][pVIP] == 2)
        {
            
InterestRate 0.02;
        }
        else if(
PlayerInfo[playerid][pVIP] == 3)
        {
            
InterestRate 0.03;
        }
        else
        {
            
InterestRate 0.01;
        }
        
PhoneBill floatround((PlayerInfo[playerid][pTexts] + PlayerInfo[playerid][pCalls])*0.75);
        
Interest floatround(PlayerInfo[playerid][pBank] * InterestRate);
        
MinutesTabbed floatround(totalTimeTab[playerid]/60);
        
MinutesReal MinutesConnected[playerid] - MinutesTabbed;
        
        if(
MinutesReal <= 0)
        {
            
MinutesReal 1;
              
PlayerLevel = (PlayerInfo[playerid][pLevel] * 2) * MinutesReal;
          }
          else
          {
              
PlayerLevel = (PlayerInfo[playerid][pLevel] * 2) * MinutesReal;
          }
        
        
printf("Interest1: %.3f"InterestRate);
        
printf("Minutes Connected: %d"MinutesConnected[playerid]);
          
printf("Minutes Tabbed: %d"MinutesTabbed);
          
printf("Minutes Total: %d"MinutesReal);
        
        
moneyGiven PlayerLevel Interest PhoneBill;
        
        
taxamount floatround(tax*moneyGiven);
        
moneyGiven -= taxamount;
        
safeamount += taxamount;
        
SendClientMessage(playeridCOLOR_WHITE"__________________ PAYDAY __________________");
        
SendClientMessageEx(playeridCOLOR_GRAD3"Money: $%d"PlayerLevel);
        
SendClientMessageEx(playeridCOLOR_GRAD4"%.3f Interest (Limit 10000): $%d"InterestRateInterest);
        
SendClientMessageEx(playeridCOLOR_GRAD4"Phone Bill: $%d"PhoneBill);
        
SendClientMessageEx(playeridCOLOR_GRAD4"Tax: %.3f percent, $%d"taxtaxamount);
        
SendClientMessageEx(playeridCOLOR_GRAD5"Total Money: $%d"moneyGiven);
         new 
extraVariableTwo 1;
        if(
DOUBLE_EXP_WEEK extraVariableTwo)
        {
              
exp moneyGiven DOUBLE_EXP_WEEK;
            
moneyGiven exp;
              
SendClientMessageEx(playeridCOLOR_GRAD5"New Total Money (Double EXP Enabled): $%d"exp);
        }
        if(
PlayerInfo[playerid][pCash] > 0SendClientMessage(playeridCOLOR_YELLOW"Your paycheck has been deposited into your bank account.");
        
SendClientMessage(playeridCOLOR_WHITE"____________________________________________");
          if(
PlayerInfo[playerid][pCash] <= 0PlayerInfo[playerid][pCash] += floatround(moneyGiven);
        else 
PlayerInfo[playerid][pBank] += floatround(moneyGiven);
        
PlayerInfo[playerid][pTexts] = 0;
        
PlayerInfo[playerid][pCalls] = 0;
        
totalTimeTab[playerid] = 0;
        
MinutesConnected[playerid] = 0;
        
PlayerInfo[playerid][pPlayingHours]++;
        
        if(
DOUBLE_EXP_WEEK extra)
        {
            
exp DOUBLE_EXP_WEEK;
            
PlayerInfo[playerid][pEXP] += exp;
        }
        else
        {
            
PlayerInfo[playerid][pEXP]++;
        }
        if(
PlayerInfo[playerid][pEXP] >= PlayerInfo[playerid][pLevel]*REQUIRED_HOURS_PER_LEVEL)
        {
              
PlayerInfo[playerid][pLevel]++;
            
PlayerInfo[playerid][pEXP] = 0;
            
SetPlayerScore(playeridPlayerInfo[playerid][pLevel]);
            
SendClientMessageEx(playeridCOLOR_YELLOW"You have leveled up to level %d. You must achieve %d more playing hours to receive level %d."PlayerInfo[playerid][pLevel], REQUIRED_HOURS_PER_LEVELPlayerInfo[playerid][pLevel]+1);
        }
        break;
    }
    return 
1;

Reply
#2

Anyone have any clue at all as to what can be causing this issue?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)