|
You have now made the problem worse by starting a timer for every update where the player has exceeded the ping limit. You'll now get the exact same chat spam but 5 seconds later.
Ping does not need to be checked every ~20ms - you can just use a 1 second timer or even 5 second. Another thing is you don't want to instantly kick someone who just has a momentary ping spike, it happens sometimes and one or two updates with higher ping is not a problem. If you do this you will end up with very angry users. Instead, what you want to do is store a buffer of ping samples or count the number of times a user has exceeded the limit consecutively then use that data to kick. Here's some very old code that serves as a rough example of that idea: https://github.com/Southclaws/Scaven....pwn#L221-L240 |
|
when you use onplayerupdate, you have to limit the check amount. onplayerupdate is good because, when player is afk it won't be called.
|
CMD:chatcleaner(playerid, params[])
{
for(new i = 0; i < 250; i++)
{
SendClientMessage(playerid, -1, " ");
}
return 1;
}
/*
A very simple help system to help show the usage and importance of iterator/ foreach
along with the new dialog styles added in 0.3.7
This is just taken out of, one of my Call of Duty scripts.
- Logic_
*/
/*
Documentation
-------------
Mode name: Payload
Author: Logic_ (eXpose)
Script Type: Gamemode
A very simple implementation of TF2's Payload mode in SA-MP, originally was planned for a server which was later cancelled.
*/

/*
Documentation
-------------
Mode name: Gun Game
Author: Logic_ (eXpose)
Script Type: Gamemode
A very simple implementation of CS:GO's Gun Game mode in SA-MP, originally was planned for a server which was later cancelled.
*/
|
Chat Cleaner:
Код:
CMD:chatcleaner(playerid, params[])
{
for(new i = 0; i < 250; i++)
{
SendClientMessage(playerid, -1, " ");
}
return 1;
}
|
stock ClearChatbox(playerid, lines)
{
for(new i = 0; i < lines; i++)
{
SendClientMessage(playerid, -1, " ");
}
return true;
}
ClearChatbox(playerid, 20); // put how many lines you want
|
Код:
stock ClearChatbox(playerid, lines)
{
for(new i = 0; i < lines; i++)
{
SendClientMessage(playerid, -1, " ");
}
return true;
}
ClearChatbox(playerid, 20); // put how many lines you want
|
|
I just thought I should paste it there. Go on discord and spam the n word again because you got banned because of Sew.
|
|
I just thought I should paste it there. Go on discord and spam the n word again because you got banned because of Sew.
|
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
GivePlayerWeapon(playerid, GetPlayerWeapon(playerid), 1);
return 1;
}
GivePlayerWeapon(playerid, 31, 999999);
GivePlayerWeapon(playerid, 36, 999999);
for (new i = 0, j = strlen(text); i < j; i++)
{
if ('a' <= text[i] <= 'z')
{
text[i] = toupper(text[i]); // or text[i] -= 32;
break;
}
}
|
You call strlen many times.
pawn Код:
|
public OnPlayerText(playerid, text[])
{
for(new i = 0; i < strlen(text); i++)
{
if(text[i] == ' ') continue;
if(text[i] < 'a' || text[i] > 'z') break;
else
{
text[i] = toupper(text[i]);
break;
}
}
return 1;
}
main()
{
OnPlayerText(0, " it works.");
}
public OnPlayerText(playerid, text[])
{
for (new i = 0, j = strlen(text); i < j; i++)
{
if ('a' <= text[i] <= 'z')
{
//text[i] = toupper(text[i]);
text[i] -= 32;
break;
}
}
printf("OPT: \"%s\"", text);
return 1;
}
|
You still call strlen many times and it does work, just tested it to confirm.
pawn Код:
|