SA-MP Forums Archive
Code Not Getting Executed Under OnPlayerUpdate - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Code Not Getting Executed Under OnPlayerUpdate (/showthread.php?tid=396308)



String Not Getting Sent Cause Of Embedded Colors - gtakillerIV - 30.11.2012

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.


Re: Code Not Getting Executed Under OnPlayerUpdate - [D]ry[D]esert - 30.11.2012

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..


Re: Code Not Getting Executed Under OnPlayerUpdate - Konstantinos - 30.11.2012

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;
}



Re: Code Not Getting Executed Under OnPlayerUpdate - gtakillerIV - 30.11.2012

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


Re: Code Not Getting Executed Under OnPlayerUpdate - Konstantinos - 30.11.2012

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


Re: Code Not Getting Executed Under OnPlayerUpdate - gtakillerIV - 30.11.2012

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.


Re: Code Not Getting Executed Under OnPlayerUpdate - Vince - 30.11.2012

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


Re: Code Not Getting Executed Under OnPlayerUpdate - Konstantinos - 30.11.2012

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;
}



Re: Code Not Getting Executed Under OnPlayerUpdate - gtakillerIV - 30.11.2012

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

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


Re: Code Not Getting Executed Under OnPlayerUpdate - Tigerkiller - 30.11.2012

how did you defined ur colours ?
like red