Code Not Getting Executed Under OnPlayerUpdate
#1

Hey guys, I made this ping limiter, but the problem is it doesn't get executed. What's wrong?

pawn Code:
public OnPlayerUpdate(playerid)
{
    if(PingWarn[playerid] == 4)
    {
        print("it got called 1");
        new kickedname[24], string[240];
        GetPlayerName(playerid, kickedname, 24);
        format(string, sizeof(string), ""red"%s "orange"Has been kicked from the Server "lime"| "orange"Reason: Reaching maximum ping warns "lime"("red"5/5"lime") |", kickedname);
        SendClientMessageToAll(Yellow, string);
        Kick(playerid);
    }
    else if(GetPlayerPing(playerid) > ServerInfo[Ping])
    {
        print("it got called 2");
        PingWarn[playerid]++;
        new string[240], name[24];
        GetPlayerName(playerid, name, 24);
        format(string, sizeof(string), ""red"%s "orange"Has recived a Ping warning "lime"| Ping: "red"%i "lime"| "orange"Ping Limit: "red"%i "lime"| "orange"Warning "red"%i/5 "lime"|", name, GetPlayerPing(playerid), ServerInfo[Ping], PingWarn[playerid]);
        SendClientMessageToAll(Yellow, string);
    }
It didin't print "it got called 1" nor did it print "it got called 2", thanks for reading.
Reply
#2

Try to make the oppsite. i mean
pawn Code:
if(GetPlayerPing(playerid) > ServerInfo[Ping])
{
//your code here
}
else if(PingWarn[playerid] == 4)
{
//your code here
}
and tell us the result..
Reply
#3

Quote:
Originally Posted by [D]ry[D]esert
View Post
Try to make the oppsite. i mean
pawn Code:
if(GetPlayerPing(playerid) > ServerInfo[Ping])
{
//your code here
}
else if(PingWarn[playerid] == 4)
{
//your code here
}
and tell us the result..
^^ That won't work.
pawn Code:
public OnPlayerUpdate(playerid)
{
    print("DEBUG_OnPlayerUpdate(playerid)");
    if(PingWarn[playerid] == 4)
    {
        print("it got called 1");
        new kickedname[24], string[240];
        GetPlayerName(playerid, kickedname, 24);
        format(string, sizeof(string), ""red"%s "orange"Has been kicked from the Server "lime"| "orange"Reason: Reaching maximum ping warns "lime"("red"5/5"lime") |", kickedname);
        SendClientMessageToAll(Yellow, string);
        Kick(playerid);
    }
    if(GetPlayerPing(playerid) > ServerInfo[Ping])
    {
        print("it got called 2");
        PingWarn[playerid]++;
        new string[240], name[24];
        GetPlayerName(playerid, name, 24);
        format(string, sizeof(string), ""red"%s "orange"Has recived a Ping warning "lime"| Ping: "red"%i "lime"| "orange"Ping Limit: "red"%i "lime"| "orange"Warning "red"%i/5 "lime"|", name, GetPlayerPing(playerid), ServerInfo[Ping], PingWarn[playerid]);
        SendClientMessageToAll(Yellow, string);
    }
    return 1;
}
Reply
#4

Still the same, but OnPlayerUpdate(The callback) itself gets called. It printed the debug.
Reply
#5

Are you sure that the PingWarn[playerid] is equal to 4?
Reply
#6

That's the thing, it doesn't get increased cause the other code doesn't get exceuted, so the above code of course will not work.
Reply
#7

pawn Code:
printf("%d > %d", GetPlayerPing(playerid), ServerInfo[Ping])
if(GetPlayerPing(playerid) > ServerInfo[Ping])
{
This is how one debugs.
Reply
#8

Then, be sure that ServerInfo[Ping] is assigned to a value.
pawn Code:
public OnPlayerUpdate(playerid)
{
    printf("if(%d > %d)", GetPlayerPing(playerid), ServerInfo[Ping] );
    if(PingWarn[playerid] == 4)
    {
        print("it got called 1");
        new kickedname[24], string[240];
        GetPlayerName(playerid, kickedname, 24);
        format(string, sizeof(string), ""red"%s "orange"Has been kicked from the Server "lime"| "orange"Reason: Reaching maximum ping warns "lime"("red"5/5"lime") |", kickedname);
        SendClientMessageToAll(Yellow, string);
        Kick(playerid);
    }
    if(GetPlayerPing(playerid) > ServerInfo[Ping])
    {
        print("it got called 2");
        PingWarn[playerid]++;
        new string[240], name[24];
        GetPlayerName(playerid, name, 24);
        format(string, sizeof(string), ""red"%s "orange"Has recived a Ping warning "lime"| Ping: "red"%i "lime"| "orange"Ping Limit: "red"%i "lime"| "orange"Warning "red"%i/5 "lime"|", name, GetPlayerPing(playerid), ServerInfo[Ping], PingWarn[playerid]);
        SendClientMessageToAll(Yellow, string);
    }
    return 1;
}
Reply
#9

It works now, but it doesn't send the messages.

It turned out that my Admin Menu was not working correctly, fixed now.
Reply
#10

how did you defined ur colours ?
like red
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)