Author Topic: [FilterScript] Ping-limit ( Adjustable ingame! )  (Read 137 times)

greentarch

  • Global Moderator
  • Newbie
  • ********
  • Posts: 16
  • Reputation: 0
    • View Profile
[FilterScript] Ping-limit ( Adjustable ingame! )
« on: April 21, 2013, 09:29:20 pm »
Hey.
One of my filterscript I made a long time ago.
It uses strcmp (no strtok's tho')

Features :
1) 2 commands :
    /setping <ping>
    /setpingwarn <warns>
2) If the player has exceeded the MAX_WARNS, the player will be kicked.

Script :
Code: [Select]
/*
Ping Limit (0.3x)
--- coded by greentarch (04/03/2012)
*/

#define FILTERSCRIPT
#include <a_samp>

new
G_MAX_PING = (900),
G_MAX_WARNS = (5);
new
G_PLAYER_PWARNS[MAX_PLAYERS];

stock bool: iznumeric(str[]) {
new i = strlen(str);
while (--i && i >=0) {
    if (!('0' <= str[i] <= '9')) return false;
}
return true;
}

public OnPlayerConnect(playerid) {
G_PLAYER_PWARNS[playerid] = 0;
SetTimerEx("PingCheck", 3000, true, "i", playerid);
return true;
}

public OnPlayerCommandText(playerid, cmdtext[]) {
if (!strcmp(cmdtext, "/setping", true, 8)) {
    if (!IsPlayerAdmin(playerid))
        return false;
if (cmdtext[8] == EOS)
    return SendClientMessage(playerid, 0xFF3333AA, "** /setping <ping>");
if (cmdtext[8] == ' ') {
strdel(cmdtext, 0, 8+1);
if (strval(cmdtext) < 1 || !iznumeric(cmdtext))
        return SendClientMessage(playerid, 0xFF3333AA, "** Invalid ping.");
G_MAX_PING = strval(cmdtext);
new
    SZ_STR[128];
format(SZ_STR, sizeof SZ_STR, "** An administrator has changed the ping limit to %d.", G_MAX_PING);
SendClientMessageToAll(0xFFFF00AA, SZ_STR);
return true;
}
}
if (!strcmp(cmdtext, "/setpingwarn", true, 12)) {
    if (!IsPlayerAdmin(playerid))
        return false;
if (cmdtext[12] == EOS)
    return SendClientMessage(playerid, 0xFF3333AA, "** /setpingwarn <warns>");
if (cmdtext[12] == ' ') {
    strdel(cmdtext, 0, 12+1);
    if (strval(cmdtext) < 1 || !iznumeric(cmdtext))
        return SendClientMessage(playerid, 0xFF3333AA, "** Invalid warns.");
G_MAX_WARNS = strval(cmdtext);
new
    SZ_STR[128];
format(SZ_STR, sizeof SZ_STR, "** An administrator has changed the ping warn limit to %d warns.", G_MAX_WARNS);
SendClientMessageToAll(0xFFFF00AA, SZ_STR);
return true;
}
}
return false;
}

forward PingCheck(playerid);
public PingCheck(playerid) {
if (GetPlayerPing(playerid) > G_MAX_PING) {
    ++ G_PLAYER_PWARNS[playerid];
    new
SZ_STR[128];
    if (G_PLAYER_PWARNS[playerid] >= G_MAX_WARNS) {
        new
            SZ_NAME[MAX_PLAYER_NAME];
GetPlayerName(playerid, SZ_NAME, MAX_PLAYER_NAME);
format(SZ_STR, sizeof SZ_STR, "** %s(%d) has been kicked for exceeding the ping limit.", SZ_NAME, playerid);
SendClientMessageToAll(0xFFFF00AA, SZ_STR);
SetTimerEx("KICK_TIMER", 100, false, "i", playerid);
return true;
}
format(SZ_STR, sizeof SZ_STR,
"** You have exceeded the ping limit! || Ping: %d || Max: %d || (Warning %d of %d)",
GetPlayerPing(playerid), G_MAX_PING, G_PLAYER_PWARNS[playerid], G_MAX_WARNS);
SendClientMessage(playerid, 0xD1D1D1AA, SZ_STR);
}
return true;
}

forward KICK_TIMER(playerid);
public KICK_TIMER(playerid) return Kick(playerid);

Don't ask me why I didn't released this thing at SA-MP forums.

Share on Bluesky Share on Facebook


Fitri

  • Newbie
  • *
  • Posts: 11
  • Reputation: 1
    • View Profile
Re: [FilterScript] Ping-limit ( Adjustable ingame! )
« Reply #1 on: April 21, 2013, 09:59:19 pm »
lol nice