Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- This is a slightly more advanced version of hustrine's anti-ping. I'm hoping it will be an improvement.
- */
- #include <a_samp>
- #include <sscanf>
- #include <zcmd>
- new MAX_PING = 1000; // Change this to your needs.
- new Warning[MAX_PLAYERS];
- forward PingCheck();
- CMD:setping(playerid, params[])
- {
- if(IsPlayerAdmin(playerid))
- {
- new NewPing, OldPing, String[128];
- if(sscanf(params, "d", NewPing))
- {
- OldPing = MAX_PING;
- format(String, sizeof(String), "{FF0000}PingCheck:{FFFFFF} The current Max ping has been changed by an administrator. Old Ping: %d, New Ping: %d", OldPing, NewPing);
- SendClientMessageToAll(-1, String);
- MAX_PING = NewPing;
- }
- }
- return 1;
- }
- public OnFilterScriptInit()
- {
- SetTimer("PingCheck", 10000, true); // Couldn't decide on this or OnPlayerUpdate
- return 1;
- }
- public OnPlayerConnect(playerid) { Warning[playerid]=0; return 1; }
- OnPlayerPingUpdate(playerid)
- {
- new String[128], PlayerName[MAX_PLAYER_NAME];
- GetPlayerName(playerid, PlayerName, MAX_PLAYER_NAME);
- if(GetPlayerPing(playerid) < MAX_PING - 100)
- {
- format(String, sizeof(String), "{FF0000}PingCheck:{FFFFFF} Your current ping is: %d. The maximum ping is %d.", GetPlayerPing(playerid), MAX_PING);
- SendClientMessage(playerid, -1, String);
- }
- if(GetPlayerPing(playerid) < MAX_PING)
- {
- switch(Warning[playerid])
- {
- case 0:
- {
- format(String, sizeof(String), "{FF0000}PingCheck:{FFFFFF} Your current ping is: %d.", GetPlayerPing(playerid));
- SendClientMessage(playerid, -1, String);
- SendClientMessage(playerid, -1, "{FF0000}PingCheck:{FFFFFF} Please try to reduce your ping by closing a few web based programs. (2/3)");
- Warning[playerid] ++;
- }
- case 1:
- {
- format(String, sizeof(String), "{FF0000}PingCheck:{FFFFFF} Your current ping is: %d.", GetPlayerPing(playerid));
- SendClientMessage(playerid, -1, String);
- SendClientMessage(playerid, -1, "{FF0000}PingCheck:{FFFFFF} Please try to reduce your ping by closing a few web based programs. (2/3)");
- Warning[playerid] ++;
- }
- case 2:
- {
- format(String, sizeof(String), "{FF0000}PingCheck:{FFFFFF} Your current ping is: %d.", GetPlayerPing(playerid));
- SendClientMessage(playerid, -1, String);
- SendClientMessage(playerid, -1, "{FF0000}PingCheck:{FFFFFF} You have recieved three warnings for excessive ping.");
- format(String, sizeof(String), "{FF0000}PingCheck{FFFFFF} %s has been kicked from the server. Reason: Excessive Ping. (%d)", PlayerName, MAX_PING);
- SendClientMessageToAll(-1, String);
- Warning[playerid] = 0;
- Kick(playerid);
- }
- }
- }
- return 1;
- }
- public PingCheck()
- {
- for(new i=0;i < MAX_PLAYERS;i++)
- {
- if(IsPlayerConnected(i))
- {
- OnPlayerPingUpdate(i);
- }
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement