AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Approved Plugins (https://forums.alliedmods.net/forumdisplay.php?f=8)
-   -   amx_blockdamage (https://forums.alliedmods.net/showthread.php?t=150039)

drekes 02-14-2011 04:03

amx_blockdamage
 
3 Attachment(s)
Description:
Enables / disables damage done by a player.


Commands:
- amx_blockdamage <name/steamid/userid> <0/1> "Block / Unblock damage done by a player."
- amx_blockdamage_list "List all the currently connected no-damage players"


Credits:
- Pan1c: Came up with the idea as a request here: http://forums.alliedmods.net/showthread.php?t=149978

Changelog:
v1.0.0: Created plugin
v1.0.1: Removed Trie
v1.0.2: Optimized code

gtpunkt 02-14-2011 04:10

Re: amx_blockdamage
 
Cool plugin,I use it on my server for the evil player :)

ConnorMcLeod 02-14-2011 04:24

Re: amx_blockdamage
 
I don't see the point on using both a trie and nvault, trie would be usefull if you would store steamids in a file to load all steamids at map start.

In fact, you never retrieve data from the trie :
Code:

        Line 37: new Trie: g_tBlockedIds;
        Line 56:        g_tBlockedIds = TrieCreate();
        Line 60:        if(g_tBlockedIds == Invalid_Trie)
        Line 78:                TrieSetCell(g_tBlockedIds, szAuthId, 1);
        Line 116:                        TrieSetCell(g_tBlockedIds, szPlayerAuth, 1);
        Line 126:                        TrieDeleteKey(g_tBlockedIds, szPlayerAuth);


drekes 02-14-2011 04:52

Re: amx_blockdamage
 
I worked with a seperate file first, and then changed it to nvault.
Guess i forgot to remove the trie.

EDIT: Removed trie

Xalus 02-15-2011 12:57

Re: amx_blockdamage
 
Maybe:

PHP Code:

        if(iNum)
        {
            
nvault_set(g_VaultszPlayerAuth"1");
            
            
g_bNoDamage[iPlayer] = true;
            
bNoDamage true;
        }
        
        else
        {
            
nvault_remove(g_VaultszPlayerAuth);
            
            
g_bNoDamage[iPlayer] = false;
            
bNoDamage false;
        } 

To

PHP Code:

if(iNum){
            
nvault_set(g_VaultszPlayerAuth"1");
        } else {
            
nvault_remove(g_VaultszPlayerAuth);
        }
        
g_bNoDamage[iPlayer] = !g_bNoDamage[iPlayer]
        
bNoDamage = !bNoDamage


drekes 02-15-2011 13:38

Re: amx_blockdamage
 
I don't think that will really matter, i have to make the if and else anyways.
And i like my way more. It's easier to see the value i just set

Xalus 02-15-2011 14:02

Re: amx_blockdamage
 
Its extra code for nothing. :)

drekes 02-15-2011 14:59

Re: amx_blockdamage
 
Imo it's more readable then yours.
If an approver tells me to change it due performance or something, i will.
If not, i'd like to keep it like it is.

EDIT: Wrecked told me that yours is less efficient because it has to retrieve the
current value first, and then change it to the opposite.

ConnorMcLeod 02-16-2011 07:20

Re: amx_blockdamage
 
Code:
        new bool:bNoDamage = g_bNoDamage[iPlayer] = !(szNum[0] == 0);                 if( bNoDamage )         {             nvault_set(g_Vault, szPlayerAuth, "1");         }         else         {             nvault_remove(g_Vault, szPlayerAuth);         }

Also, you can lower names and authids arrays to 32 cells

drekes 02-16-2011 08:03

Re: amx_blockdamage
 
Done


All times are GMT -4. The time now is 16:09.

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