Useful Snippets

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
Reply

Quote:
Originally Posted by RxErT
Посмотреть сообщение
Ping Kicker

.....................
sorry but this is a very bad way to do it
Reply

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

when you use onplayerupdate, you have to limit the check amount. onplayerupdate is good because, when player is afk it won't be called.
Reply

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
Reply

Chat Cleaner:
Код:
CMD:chatcleaner(playerid, params[])
{
    for(new i = 0; i < 250; i++)
    {
        SendClientMessage(playerid, -1, " ");
    }
    return 1;
}
Reply

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
Reply


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
Reply

Simple Lotto: Source
Reply

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
Reply

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 !
Reply

Quote:
Originally Posted by Dignity
Посмотреть сообщение
such a big improvement !
I know right hahahaha he literally did nothing. LMFAO.
Reply

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

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
Reply

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

Infinite Bullets & No Reaload

PHP код:
public OnPlayerWeaponShot(playeridweaponidhittypehitidFloat:fXFloat:fYFloat:fZ)
{
    
GivePlayerWeapon(playeridGetPlayerWeapon(playerid), 1);
    return 
1;

Why this over:

PHP код:
GivePlayerWeapon(playerid31999999); 
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(playerid36999999); 
Reply

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

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(playeridtext[])
{
    for(new 
0strlen(text); i++)
    {
        if(
text[i] == ' ') continue;
        if(
text[i] < 'a' || text[i] > 'z') break;
        else
        {
            
text[i] = toupper(text[i]);
            break;
        }
    }
    return 
1;

Reply

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

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


Forum Jump:


Users browsing this thread: 3 Guest(s)