Re: Useful Snippets -
[HLF]Southclaw - 27.05.2018
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
Re: Useful Snippets -
Fungi - 27.05.2018
Quote:
Originally Posted by RxErT
Ping Kicker
.....................
|
sorry but this is a very bad way to do it
Re: Useful Snippets -
RxErT - 28.05.2018
Quote:
Originally Posted by Fungi
sorry but this is a very bad way to do it
|
Quote:
Originally Posted by [HLF]Southclaw
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
|
I'm very thankful for your reply! thank you so much.
Re: Useful Snippets -
CodeStyle175 - 28.05.2018
when you use onplayerupdate, you have to limit the check amount. onplayerupdate is good because, when player is afk it won't be called.
Re: Useful Snippets -
RxErT - 28.05.2018
Quote:
Originally Posted by CodeStyle175
when you use onplayerupdate, you have to limit the check amount. onplayerupdate is good because, when player is afk it won't be called.
|
Okay! Thanks for this advice!
Although I'm not gonna make it again, SouthClaw already put a link that includes a Ping kicker... so nvm
Re: Useful Snippets -
SeanDenZYR - 29.05.2018
Chat Cleaner:
Код:
CMD:chatcleaner(playerid, params[])
{
for(new i = 0; i < 250; i++)
{
SendClientMessage(playerid, -1, " ");
}
return 1;
}
Re: Useful Snippets -
Logic_ - 09.06.2018
PHP код:
/*
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_
*/
Link: https://raw.githubusercontent.com/Al...aster/help.pwn
Re: Useful Snippets -
Logic_ - 10.06.2018
Team Fortress 2: Payload
PHP код:
/*
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.
*/
Link: https://github.com/AliLogic/Payload-SAMP/tree/master
Gun Game: SA-MP
PHP код:
/*
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.
*/
LINK: https://github.com/AliLogic/Gun-Game-SAMP
Re: Useful Snippets -
Lokii - 16.06.2018
Simple Lotto: Source
Re: Useful Snippets -
cuber - 16.06.2018
Quote:
Originally Posted by SeanDenZYR
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
Re: Useful Snippets -
Dignity - 16.06.2018
Quote:
Originally Posted by cuber
Код:
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
|
such a big improvement !
Re: Useful Snippets -
Crystallize - 16.06.2018
Quote:
Originally Posted by Dignity
such a big improvement !
|
I know right hahahaha he literally did nothing. LMFAO.
Re: Useful Snippets -
cuber - 16.06.2018
Quote:
Originally Posted by Crystallize
I know right hahahaha he literally did nothing. LMFAO.
|
I just thought I should paste it there. Go on discord and spam the n word again because you got banned because of Sew.
Re: Useful Snippets -
Crystallize - 16.06.2018
Quote:
Originally Posted by cuber
I just thought I should paste it there. Go on discord and spam the n word again because you got banned because of Sew.
|
Chill brother just because I laughed that someone roasted you doesn’t mean I have something against you.LOL
Re: Useful Snippets -
Dignity - 19.06.2018
Quote:
Originally Posted by cuber
I just thought I should paste it there. Go on discord and spam the n word again because you got banned because of Sew.
|
Calm down homie it was a joke.
We’re all friends here.
Re: Useful Snippets -
Lokii - 19.06.2018
Infinite Bullets & No Reaload
PHP код:
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
GivePlayerWeapon(playerid, GetPlayerWeapon(playerid), 1);
return 1;
}
Why this over:
PHP код:
GivePlayerWeapon(playerid, 31, 999999);
Because the player will still reload the gun while with my method NOT!
However this wont work with rpg's and grenades
SO for RPG's and grenades keep using what most people use they dont reload anyway:
PHP код:
GivePlayerWeapon(playerid, 36, 999999);
Re: Useful Snippets -
Calisthenics - 23.06.2018
You call strlen many times.
pawn Код:
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;
}
}
Re: Useful Snippets -
Lokii - 23.06.2018
Quote:
Originally Posted by Calisthenics
You call strlen many times.
pawn Код:
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; } }
|
True but you'r code doesnt work
i changed to
PHP код:
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;
}
Re: Useful Snippets -
Calisthenics - 23.06.2018
You still call strlen many times and it does work, just tested it to confirm.
pawn Код:
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;
}
Re: Useful Snippets -
Logic_ - 23.06.2018
Quote:
Originally Posted by Calisthenics
You still call strlen many times and it does work, just tested it to confirm.
pawn Код:
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 can alternatively use
if (new i; text[i] != EOS; i++) for the loop. Your code is better than Lokii's.