Code Crashing / Lagging Sever Hardstyle!
#1

This code seems to be crashing / lagging the server this only started when i added the colours in.
pawn Код:
public systemclock()
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
new string[156];
format(string, sizeof(string), "~r~Time Left: ~w~%d:%d", RestartMinn,RestartSecc);
TextDrawSetString(txtTypeClock, string);
if(RestartSecc == 9 || RestartSecc == 8 || RestartSecc == 7 || RestartSecc == 6 || RestartSecc == 5 || RestartSecc == 4 || RestartSecc == 3 || RestartSecc == 2 || RestartSecc == 2 || RestartSecc == 1 || RestartSecc == 0)
{
format(string, sizeof(string), "~r~Time Left: ~w~%d:0%d", RestartMinn,RestartSecc);
TextDrawSetString(txtTypeClock, string);
}
}
}
Reply
#2

I dont think this would fix it but just lookin at your code, your if statement wouldnt it be better to have if(RestartSecc < 10)?
Reply
#3

Try this, I have no idea what the MAX_PLAYER loop is acctually doing in there.

pawn Код:
public systemclock()
{
    new string[156];
   
    switch(RestartSecc)
    {
        case 0...9: format(string, sizeof(string), "~r~Time Left: ~w~%d:0%d", RestartMinn,RestartSecc);
        default: format(string, sizeof(string), "~r~Time Left: ~w~%d:%d", RestartMinn,RestartSecc);
    }

    TextDrawSetString(txtTypeClock, string);
}
Reply
#4

Fixed, The problem was i forgot to add IsPlayerConnected
Reply
#5

Quote:
Originally Posted by KyleSmith
Fixed, The problem was i forgot to add IsPlayerConnected
You don't need the loop! It is doing nothing in there! Just running the code for however many players you have connected doesn't change the overall outcome of this particular result. Some cases you definately require loops, but this is most certainly not one of them, try the code I posted and it should give you the same result, but much more quickly.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)