Raised This Month: $51 Target: $400
 12% 

amx_blockdamage


Post New Thread Reply   
 
Thread Tools Display Modes
Plugin Info:     Modification:   ALL        Category:   Admin Commands        Approver:   ConnorMcLeod (74)
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 02-14-2011 , 04:03   amx_blockdamage
Reply With Quote #1

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
Attached Files
File Type: sma Get Plugin or Get Source (amx_blockdamage.sma - 1687 views - 3.9 KB)
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.

Last edited by drekes; 02-16-2011 at 08:03.
drekes is offline
Send a message via MSN to drekes
gtpunkt
Veteran Member
Join Date: Dec 2008
Location: Berlin
Old 02-14-2011 , 04:10   Re: amx_blockdamage
Reply With Quote #2

Cool plugin,I use it on my server for the evil player

Last edited by gtpunkt; 02-14-2011 at 06:09.
gtpunkt is offline
Send a message via Skype™ to gtpunkt
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 02-14-2011 , 04:24   Re: amx_blockdamage
Reply With Quote #3

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);
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 02-14-2011 , 04:52   Re: amx_blockdamage
Reply With Quote #4

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

EDIT: Removed trie
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
Xalus
Veteran Member
Join Date: Dec 2009
Location: Belgium
Old 02-15-2011 , 12:57   Re: amx_blockdamage
Reply With Quote #5

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
__________________
Retired.
Xalus is offline
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 02-15-2011 , 13:38   Re: amx_blockdamage
Reply With Quote #6

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
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
Xalus
Veteran Member
Join Date: Dec 2009
Location: Belgium
Old 02-15-2011 , 14:02   Re: amx_blockdamage
Reply With Quote #7

Its extra code for nothing.
__________________
Retired.
Xalus is offline
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 02-15-2011 , 14:59   Re: amx_blockdamage
Reply With Quote #8

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

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.

Last edited by drekes; 02-15-2011 at 15:33.
drekes is offline
Send a message via MSN to drekes
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 02-16-2011 , 07:20   Re: amx_blockdamage
Reply With Quote #9

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
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 02-16-2011 at 07:23.
ConnorMcLeod is offline
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 02-16-2011 , 08:03   Re: amx_blockdamage
Reply With Quote #10

Done
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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