Function Bugs.
#1

Cheers,

I have a Cooldown and Interest Timer in my Server.
Its Timer Works well but when function executes and when there are more than 10 players in server.
It starts spamming..

Here is the codes:
PHP код:
public CooldownTimer(playerid)
{
    new 
msg[120];
    if(
Player[playerid][playerWanted] > )
    {
        
Player[playerid][playerWanted]--;
        
format(msg,sizeof(msg),"Your wanted level has been reduced to %d.",Player[playerid][playerWanted]);
        
SendClientMessage(playerid,COLOR_YELLOW,msg);
        
setWanted(playerid,Player[playerid][playerWanted]);
        return 
1;
    }
    else
    {
        
TextDrawHideForPlayer(playeridGM[loadObjectTD][0]);
    }
    return 
1;

and here is the interest timer code:
PHP код:
public InterestTimer(playerid)
{
    new 
giveintr,deduction,msg3[100];
    
Player[playerid][interestTimer]++;
    
//SendClientMessage(playerid,COLOR_YELLOW,"DEBUG: ID 1");
    
if(Player[playerid][interestTimer] >= 10)
    {
         
deduction 10000;
         
giveintr Player[playerid][moneyBank]/deduction;
         
Player[playerid][interest] = Player[playerid][interest] + giveintr;
         
format(msg3,sizeof(msg3),"You have recieved your interest payment of $%s. Head to nearest local bank to collect it.",FormatNumber(giveintr));
         
SendClientMessage(playerid,COLOR_YELLOW,msg3);
         
Player[playerid][interestTimer] = 0;
         return 
1;
    }
    return 
1;

Thnx..
Reply
#2

will there be a problem if i use break instead if return ?
Reply
#3

You are not in a loop, break won't do anything. You showed only timer functions, show also how you set up the timer.
Reply
#4

Show the timers setup and this function

setWanted(playerid,Player[playerid][playerWanted]);

setWanted();
Reply
#5

well the timer starts onplayerlogin
its like Cooldowntimer = SetTimerEx("Cooldown",180000,true,"d",playerid);

same method for interest timer....
Reply
#6

Quote:
Originally Posted by Shaheen
Посмотреть сообщение
well the timer starts onplayerlogin
its like Cooldowntimer = SetTimerEx("Cooldown",180000,true,"d",playerid);

same method for interest timer....
And which timer is spamming?
Reply
#7

both the timers are spamming sometimes..
Reply
#8

When do you set the timer?

Don't use a global (non player) variable to set timers to players.
Reply
#9

PHP код:
case DIALOG_LOGIN:
        {
            if(!
response)
                return 
KickDelay(playerid);
                
            
WP_Hash(hashsizeof(hash), inputtext);
            if(!
strcmp(hashPlayer[playerid][playerPassword], true))
            {
                new 
country[256];
                
GetPlayerCountry(playeridcountrysizeof(country));
                
format(message256"{0066ff}* %s(%d) has connected to the server from %s."GetName(playerid),playerid,country);
                
SendClientMessageToAll(COLOR_WHITE,message);
                
//ShowPlayerDialog(playerid, DIALOG_UNUSED, DIALOG_STYLE_MSGBOX, "Welcome back", message, "Submit", "");
                
Player[playerid][tryLogin]        =    0;
                
Player[playerid][playerLogged]    =    GetTickCount();
                
Player[playerid][useCommand]    =    true;
                
Player[playerid][loggedIn]        =    true;
                
Player[playerid][savedHealth]    =     0;
                
Player[playerid][cooldown] = SetTimerEx("CooldownTimer",180000true"d"playerid); //Wanted level reducing timer (5 mins)
                
Player[playerid][intresttimer] = SetTimerEx("InterestTimer",360000true"d"playerid); //Interest Timer (6 mins update) //3600000
                
initTextdraw(playerid);

            }
            else
            {
                
Player[playerid][tryLogin]++;
                if(
Player[playerid][tryLogin] < 3)
                {
                    new 
pesan[300];
                    
//format(message, 256, CHAT_WHITE"Wrong password, \nPlease enter your password in the field below. (%d/3)", Player[playerid][tryLogin]);
                    //ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Login", message, "Login", "Leave");
                    
format(pesansizeof(pesan), "{ffffff}Welcome to Los Santos {0066ff}Cops {ffffff}and {ff0000}Robbers.\n\n{ffffff}User Name: {ff7a00}%s.\n{ffffff}Ip Address: {ff7a00}%s\n\n{ff0000}You have entered a wrong password (%d/3)\n{ffffff}Enter your password.."GetName(playerid),getIP(playerid),Player[playerid][tryLogin]);
                    
ShowPlayerDialog(playeridDIALOG_LOGINDIALOG_STYLE_PASSWORD"LSCNR - LOGIN"pesan"Login""Quit");
                    
                }
                else
                {
                    
ShowPlayerDialog(playeridDIALOG_UNUSEDDIALOG_STYLE_MSGBOX"Wrong Password""You have mistyped your password too often (3 times)""Okay""");
                    
KickDelay(playerid);
                }
            }
        } 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)