Raised This Month: $32 Target: $400
 8% 

Silent Nades .:silence is your friend:.


Post New Thread Reply   
 
Thread Tools Display Modes
VEN
Veteran Member
Join Date: Jan 2005
Old 04-19-2007 , 04:37   Re: Silent-Nades
Reply With Quote #11

Quote:
#define MAXPLAYERS 32
new bool:g_player_FITH[MAXPLAYERS][2];
You should create array with size MAXPLAYERS + 1 because first array element index is 0 and first client index is 1. In other case you'll get index out of bounds error for 32nd client on 32-slot server.

Anything below is a hints.

Quote:
for (new i; i < 32; ++i)
{
g_player_FITH[i][0] = false;
g_player_FITH[i][1] = false;
}
This is not necessary because in Pawn variables is "zeroed" on initialization.

Quote:
public welcome(id)
{
if (!get_pcvar_num(g_sn_enabled)) return PLUGIN_HANDLED;
You better check for plugin mode on task creation as well to possibly avoid unnecessary task creation. Also return PLUGIN_HANDLED and return 0 not needed. This is not blockable fuction. You should keed consistency for function return values. If you use PLUGIN_* use it for every return in your function. But as i said return PLUGIN_HANDLED will not make any difference. In this situation i'd recommend simply use return without any specific value.

You shouldn't really care about letters case in user messages arguments. Since it is hardcoded into the game and never change its letter case.

Also a hint. You can use set_user_info() to store personal client configuration into UserInfo buffer. This will allow to keep configuration for every specific client until his actual disconnect. Buffer will not be cleared on changelevel or reconnect. Note that better set a short key name and key value to not clutter up UserInfo buffer.

For example this is how i'd do that. key name: "_fith", key value: "3". 3 is ((1<<0) | (1<<1)) - so this mean that audio and text is disabled. If you familiar with bitwise operations you'll get what i mean and how to deal with it. If not then you can do it in similar manner but without bitwise operations. And also maybe make amx_silentnades CVar functionality in the same manner to provide more flexibility. If you don't like digits you can use for example "ab" letters/flags. But again it will be converted into bitwise-like form if you going to use read_flags().

If you interested in learning more about bitwise operations you can visit this page http://wiki.amxmodx.org/index.php/Pawn. It's cover Pawn scripting basics.
VEN is offline
regalis
Veteran Member
Join Date: Jan 2007
Location: F*cking Germany
Old 04-19-2007 , 05:16   Re: Silent-Nades
Reply With Quote #12

Quote:
Originally Posted by VEN View Post
You should create array with size MAXPLAYERS + 1 because first array element index is 0 and first client index is 1. In other case you'll get index out of bounds error for 32nd client on 32-slot server.

Anything below is a hints.
Ah i thought about it but wasn't sure...thanks ;)
(btw: I have seen that in an other approved plugin...maybe i should PM the author )

Quote:
Originally Posted by VEN View Post
This is not necessary because in Pawn variables is "zeroed" on initialization.

You better check for plugin mode on task creation as well to possibly avoid unnecessary task creation. Also return PLUGIN_HANDLED and return 0 not needed. This is not blockable fuction. You should keed consistency for function return values. If you use PLUGIN_* use it for every return in your function. But as i said return PLUGIN_HANDLED will not make any difference. In this situation i'd recommend simply use return without any specific value.
Thank you for that hint..i'm not always sure what return value is the best
Hope in my next Verison all will be correct

Quote:
Originally Posted by VEN View Post
You shouldn't really care about letters case in user messages arguments. Since it is hardcoded into the game and never change its letter case.
Ops, thought that would be the correct way...
I'll change that in the next version!

Quote:
Originally Posted by VEN View Post
Also a hint. You can use set_user_info() to store personal client configuration into UserInfo buffer. This will allow to keep configuration for every specific client until his actual disconnect. Buffer will not be cleared on changelevel or reconnect. Note that better set a short key name and key value to not clutter up UserInfo buffer.
I wondered how to make that the settings will last till the client disconnect.
Thought about NVAULT, but haven't got time to look at it...Now i got it...thank you very much!

Quote:
Originally Posted by VEN View Post
For example this is how i'd do that. key name: "_fith", key value: "3". 3 is ((1<<0) | (1<<1)) - so this mean that audio and text is disabled. If you familiar with bitwise operations you'll get what i mean and how to deal with it. If not then you can do it in similar manner but without bitwise operations. And also maybe make amx_silentnades CVar functionality in the same manner to provide more flexibility. If you don't like digits you can use for example "ab" letters/flags. But again it will be converted into bitwise-like form if you going to use read_flags().

If you interested in learning more about bitwise operations you can visit this page http://wiki.amxmodx.org/index.php/Pawn. It's cover Pawn scripting basics.

OMG!
Now it's getting hard
I'll try it first with digits and when i'm familiar with the bitwise operations thingy i'll try that one...but it maybe take ages *fg*
Btw.: it seems not many plugins use this style!?
All together nice hints!
Thank you
regalis
__________________
regalis is offline
VEN
Veteran Member
Join Date: Jan 2005
Old 04-19-2007 , 11:48   Re: Silent-Nades
Reply With Quote #13

Quote:
Ops, thought that would be the correct way...
I'll change that in the next version!
I didn't said that your way was incorrect. I just explained why there will be no difference with use equal()/equali(). Your way is also correct.

Quote:
Thought about NVAULT
In general use of nvault would be more useful if you going to keep personal settings even after client disconnect. If not, then use of UserInfo buffer would be enough. Although i'd personally use separate config file instead of nvault.

Quote:
Now it's getting hard
This is simple enough.

Let's say that you have a CVar: my_cvar "ab"
You get CVar value and then do: new flags = read_flags(cvar_value)
And then:
Code:
if (flags & (1<<0)) // check for "a" flag, (1<<0) == 1 and corresponds to "a"         // do something if (flags & (1<<1)) // check for "b" flag, (1<<1) == 2 and corresponds to "b"         // do something

Also i didn't get why would you need additional console commands? You can execute: amx_cvar my_cvar value

Last edited by VEN; 04-19-2007 at 11:53.
VEN is offline
regalis
Veteran Member
Join Date: Jan 2007
Location: F*cking Germany
Old 04-19-2007 , 13:38   Re: Silent-Nades
Reply With Quote #14

Quote:
Originally Posted by VEN View Post
I didn't said that your way was incorrect. I just explained why there will be no difference with use equal()/equali(). Your way is also correct.
ok, i have changed it because i didn't know if there is a optimization disadvantage. Maybe equali() use internal more comparisons than just equal()
If not, never mind

Quote:
Originally Posted by VEN View Post
In general use of nvault would be more useful if you going to keep personal settings even after client disconnect. If not, then use of UserInfo buffer would be enough. Although i'd personally use separate config file instead of nvault.
Separate config files is another thing that i have to learn
Maybe in my next plugin...
But you are right userinfo is just perfect in this case, good that i have you ;)
Otherwise i would have used nvault...0o

Quote:
Originally Posted by VEN View Post
This is simple enough.

Let's say that you have a CVar: my_cvar "ab"
You get CVar value and then do: new flags = read_flags(cvar_value)
And then:
Code:
if (flags & (1<<0)) // check for "a" flag, (1<<0) == 1 and corresponds to "a" // do something if (flags & (1<<1)) // check for "b" flag, (1<<1) == 2 and corresponds to "b" // do something
Ok, then "c" would be (1<<2) ?
and "d" = (1<<3)?
That is quite simple
And with letters instead of digits quite cool *hehe*
Then i can use "s" (1<<1 for sound and "m" (1<<12) for messages...
I like that!
Thank you so much for your help!

Quote:
Originally Posted by VEN View Post
Also i didn't get why would you need additional console commands? You can execute: amx_cvar my_cvar value
I don't know this command(amx_cvar)!?
Is it bad to have console commands?
I mean better more commands than none...^^

greetz regalis
__________________

Last edited by regalis; 04-19-2007 at 13:45. Reason: typo *g*
regalis is offline
VEN
Veteran Member
Join Date: Jan 2005
Old 04-19-2007 , 14:13   Re: Silent-Nades
Reply With Quote #15

Quote:
Maybe equali() use internal more comparisons than just equal()
Correct, though it isn't noticeable. My point was that equali() should be used only when it is really needed. If coder use it everywhere he probably don't understand what is going on in his code.

Quote:
That is quite simple
If course. You get it right.

Quote:
You can execute: amx_cvar my_cvar value
I meant that admin can use default AMX Mod X amx_cvar command to change modes thorugh CVars instead of using your command. But your command has a description that admin can read with amx_help command so in fact your command is informative. It may be useful for admins that do not know about CVars existence but know how to use amx_help.
VEN is offline
bmann_420
AMX_Super Pooper
Join Date: Jan 2005
Location: [SuperCentral.co]
Old 04-20-2007 , 17:17   Re: Silent-Nades
Reply With Quote #16

Very Useful and great Idea came to life

I would use it, but I like to find out who teamflashed me most of the time, lol Or else I would.
__________________
bmann_420 is offline
regalis
Veteran Member
Join Date: Jan 2007
Location: F*cking Germany
Old 04-20-2007 , 20:18   Re: Silent-Nades
Reply With Quote #17

I got a plugin from JGHG here, but i didn't find it anymore
I load it up for you maybe it works...haven't tested it yet ;)
Here we go: "Blind" from JGHG (i hope thats ok!?)

greetz regalis

PS: with silent-nades you can configure personaly if you want to hear the sounds or read the messages from the nades...every user have his own preferences ;)
Attached Files
File Type: sma Get Plugin or Get Source (WhoBlindedWho.sma - 736 views - 4.1 KB)
__________________

Last edited by regalis; 04-20-2007 at 20:19. Reason: forget the main answer *lol*
regalis is offline
VEN
Veteran Member
Join Date: Jan 2005
Old 04-22-2007 , 09:45   Re: Silent-Nades
Reply With Quote #18

Content of toggle_mode() and toggle_sn() functions should be shorter. Don't repeat the same blocks of code like that, it isn't needed at all. For example you can move a commonly used blocks of code to separate functions and then use them.

In welcome() and client_info() functions it's better take set_hudmessage() out of switch.

Last edited by VEN; 04-22-2007 at 11:41.
VEN is offline
regalis
Veteran Member
Join Date: Jan 2007
Location: F*cking Germany
Old 04-22-2007 , 12:57   Re: Silent-Nades
Reply With Quote #19

Thanks VEN for the hints and the approval!

+Code optimized and because approval version changed to 1.0!
New Version uploaded

greetz regalis
__________________
regalis is offline
bmann_420
AMX_Super Pooper
Join Date: Jan 2005
Location: [SuperCentral.co]
Old 04-22-2007 , 15:51   Re: Silent-Nades .:because silence is your friend:.
Reply With Quote #20

Yea, im using it now. WIthout the whoflashedwho since that is like shooting through the wall and using /me ;) Its a dead giveaway lol. But I like this overall, GJ
__________________
bmann_420 is offline
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 21:28.


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