AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   New Plugin Submissions (https://forums.alliedmods.net/forumdisplay.php?f=26)
-   -   Radio Gag System (https://forums.alliedmods.net/showthread.php?t=347394)

CT_Spawn 04-22-2024 11:40

Radio Gag System
 
3 Attachment(s)
Radio Gag System

Description:
  • This plugin is to silence annoying people who spam radio messages (note that the plugin does not depend on a database, it only works once per map)

Commands Usage:
  • amx_rgag <nick | authid | #userid> (for gag radio spammer by name or steamid or 'userid but use # before userid' )
  • amx_ip_rgag <ip> (for gag radio spammer by ip)
  • amx_unrgag <nick | authid | #userid> (for ungag radio user by name or steamid or 'userid but use # before userid' )
  • amx_ip_unrgag <ip> (for ungag radio user by ip)
Video:


Screenshot:


bigdaddy424 04-22-2024 23:05

Re: Radio Gag System
 
good idea but poorly executed
very hardcoded and i recommend browsing the web api and in this case reading about Trie array...
https://www.amxmodx.org/api
https://forums.alliedmods.net/showthread.php?t=201872
and since youre blocking `STEAM_ID_LAN` and `localhost` where this only happens when youre running a lan server than theres a function that detects just that `is_dedicated_server`

CT_Spawn 04-23-2024 15:38

Re: Radio Gag System
 
Quote:

Originally Posted by bigdaddy424 (Post 2821446)
good idea but poorly executed
very hardcoded and i recommend browsing the web api and in this case reading about Trie array...
https://www.amxmodx.org/api
https://forums.alliedmods.net/showthread.php?t=201872
and since youre blocking `STEAM_ID_LAN` and `localhost` where this only happens when youre running a lan server than theres a function that detects just that `is_dedicated_server`

Thanks for your comment and ideas
But regarding dynamic arrays
I actually intended to work with it, but I changed my mind and put static arrays
Because I didn't trust the plugin_end function
And you know that the server works 24/24 and 7/7
If there is an error in the plugin_end function, the memory will fill up with arrays. This will do more harm than good.

That's why I decided to put static

Detecting the IP using the is_dedicated_server function is a good idea, but I think I will not update it for this reason only.

As for the percentage of STEAM_ID_LAN and others

You are completely wrong, because I have seen cases of some players entering the server with these IDs

Regarding the latter, above all this, this code is a quote from the official admincmd.sma

bigdaddy424 04-23-2024 21:48

Re: Radio Gag System
 
in order to occupy around 1mb of ram memory you need an array of 20-30k entries so its safe to say that memory isnt an excuse not that it ever has been something to consider especially working on mods for games.
the last major update admincmd.sma file has had was when 1.75 was introduced according to some sources and this was in 2007 or 2008. since then there've been minor edits and additions. theres no such cases as players having STEAM_ID_LAN on multiplayer, unless you account for reunion or dproto which is against ToS.

CT_Spawn 04-24-2024 09:06

Re: Radio Gag System
 
Quote:

Originally Posted by bigdaddy424 (Post 2821500)
in order to occupy around 1mb of ram memory you need an array of 20-30k entries so its safe to say that memory isnt an excuse not that it ever has been something to consider especially working on mods for games.
the last major update admincmd.sma file has had was when 1.75 was introduced according to some sources and this was in 2007 or 2008. since then there've been minor edits and additions. theres no such cases as players having STEAM_ID_LAN on multiplayer, unless you account for reunion or dproto which is against ToS.

https://i.imgur.com/9uwubRT.jpeg

image link
You get this picture. Don't deny it, I saw it myself, my friend

WATCH_D0GS UNITED 04-24-2024 12:33

Re: Radio Gag System
 
PHP Code:

new array_cells[30000

32-bit system:

30000 * 4 = 120000

120000 Bytes -> 0.114 Megabytes

64-bit system:

0.228 Megabytes

Jhob94 04-24-2024 12:39

Re: Radio Gag System
 
Quote:

Originally Posted by CT_Spawn (Post 2821535)
https://i.imgur.com/9uwubRT.jpeg

image link
You get this picture. Don't deny it, I saw it myself, my friend

I did not understand what you meant by dproto, but if you meant that the server targets “non steam player”, the server definitely targets them. Who is the idiot who opens a server and does not put dproto in it?

First you have no idea what you are doing and you should consider learn more before posting plugins.
Second you should read rules, we do not support non-steam. If people use, we don’t care, but we do not support it so don’t say that kind of things.
Third, no one is idiot for wanting steam only servers, they are cleaner.

CT_Spawn 04-28-2024 19:35

Re: Radio Gag System
 
Quote:

Originally Posted by WATCH_D0GS UNITED (Post 2821549)
PHP Code:

new array_cells[30000

32-bit system:

30000 * 4 = 120000

120000 Bytes -> 0.114 Megabytes

64-bit system:

0.228 Megabytes

32*32*4=4096 .....(1)
+
39*32*4=4992 ....(2)

(1) + (2) = 9088 Bytes
************************
24 * 60 = 1440 minutes

map time = 10 minutes
1440/10 ======> have 144 map in one day
so
9088 * 144 = 1308672 Bytes = 1.25 mb in one day

so
1.25 * 30 = 37.5 mb in 1 month

so
37.5*12=450 mb

This is just what we calculated on my plugin

So what if we count the other plugins?
Also, the system and the server software, we assume that they both carry 750 MB without taking into account additional other plugins, and I add only my 450 MB program to them.

That means the total is 1.2 GB
Imagine that the server only has 1 GB of RAM


It's strange to see a programmer bragging about memory loss like you

Didn't you study web programming and learn from it that you should do your best to reduce the volume, even if it is small?

bigdaddy424 04-28-2024 22:46

Re: Radio Gag System
 
Quote:

Originally Posted by CT_Spawn (Post 2821535)
https://i.imgur.com/9uwubRT.jpeg

image link
You get this picture. Don't deny it, I saw it myself, my friend

that activity only happens when running a non steam server
Quote:

Originally Posted by CT_Spawn (Post 2821758)
32*32*4=4096 .....(1)
+
39*32*4=4992 ....(2)

(1) + (2) = 9088 Bytes
************************
24 * 60 = 1440 minutes

map time = 10 minutes
1440/10 ======> have 144 map in one day
so
9088 * 144 = 1308672 Bytes = 1.25 mb in one day

so
1.25 * 30 = 37.5 mb in 1 month

so
37.5*12=450 mb

This is just what we calculated on my plugin

So what if we count the other plugins?
Also, the system and the server software, we assume that they both carry 750 MB without taking into account additional other plugins, and I add only my 450 MB program to them.

That means the total is 1.2 GB
Imagine that the server only has 1 GB of RAM


It's strange to see a programmer bragging about memory loss like you

Didn't you study web programming and learn from it that you should do your best to reduce the volume, even if it is small?

im not sure what you mean about these numbers but youre taking it on extreme levels. my lazy calculations were made using nvault_set on a loop 30000 times and the result came to about 1.5mb
PHP Code:

#include <amxmodx>
#include <nvault>

public plugin_init()
{
    new 
k[MAX_NAME_LENGTH], nvault_open("v")
    for (new 
030000i++)
    {
        for (new 
0MAX_NAME_LENGTHj++)
            
k[j] = random_num(97122)
        
nvault_set(vkNULL_STRING)
        
server_print "%d[%s]"ik
    
}
    
nvault_close(v)


we're going against all odds when we assume banning 30'000 players. daily player base of counter-strike peaks around 15'000 and majority are players who play everyday https://steamdb.info/app/10/charts/
ive been mining steam ids using nvault to save certain values and this has been going on from around 3 years and ive accumulated around 7000 unique players. this includes players who connected to the server by mistake, players having multiple accounts and those using family sharing with friends. now do the math

WATCH_D0GS UNITED 04-29-2024 12:44

Re: Radio Gag System
 
Quote:

Originally Posted by CT_Spawn (Post 2821758)
32*32*4=4096 .....(1)
+
39*32*4=4992 ....(2)

(1) + (2) = 9088 Bytes
************************
24 * 60 = 1440 minutes

map time = 10 minutes
1440/10 ======> have 144 map in one day
so
9088 * 144 = 1308672 Bytes = 1.25 mb in one day

so
1.25 * 30 = 37.5 mb in 1 month

so
37.5*12=450 mb

This is just what we calculated on my plugin

So what if we count the other plugins?
Also, the system and the server software, we assume that they both carry 750 MB without taking into account additional other plugins, and I add only my 450 MB program to them.

That means the total is 1.2 GB
Imagine that the server only has 1 GB of RAM


It's strange to see a programmer bragging about memory loss like you

Didn't you study web programming and learn from it that you should do your best to reduce the volume, even if it is small?

Who are you mentioning in the end of your comment?

These calculations you did makes no sense man.

PHP Code:

    new steamid[32],ip[39

These variables were created locally inside the public function in your plugin, which means they are created in the moment the function is called.
Their memory is allocated in the moment they are created, and deallocated/deleted/freed as soon as the function execution ends.

All this is handled by your server computer at runtime.

Differently of this, global variables memory usage is kept during all the time your plugin is running and their memory usage does not change during gameplay.

PHP Code:

new global_variable_outside_codeblock

In Small (Pawn) this integer-type variable will occupy 4 bytes in a 32-bit system and 8 bytes in a 64-bit system.

This memory will be released only when the server shuts down.


For example, this is what occurs supposing your function is called every time a player connects:

Using local variables (RAM friendly, CPU expensive)
PHP Code:

public On_Client_Connect(id) {
    
// Creates the variables and allocate their memory as soon as a player connects.
    
new steamid[32],ip[39]

    if(
something(steamid || ip)) {
        
make_something
    
}
    
}   
// Deletes the variables and frees their memory after all the steps are finished. 



Using global variables (RAM expensive, CPU friendly)

PHP Code:

// Creates the variables and allocate their memory once when the plugin is initialized.
//This is outside the code blocks.
new steamid[32],ip[39]

public 
On_Client_Connect(id) {

    if(
something(steamid || ip)) {
        
make_something
    
}
    


This code will execute faster, although the memory used by the variables will not be freed.


All times are GMT -4. The time now is 20:31.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.