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

WordGame


Post New Thread Reply   
 
Thread Tools Display Modes
Plugin Info:     Modification:   ALL        Category:   Fun Stuff       
hLiaS
Senior Member
Join Date: Aug 2011
Location: In My Holly Dreams
Old 05-26-2013 , 07:11   WordGame
Reply With Quote #1

WordGame
version 1.0
by Larisaios(me)

First of all i want to say, that i don't know good english.

Description
This is a plugin for jailbreak servers, but you can use it with other mods too.

To use wordgame you must be an admin or a player on CT Team...
You just type the command and then you will see on your up left corner of your screen
a messagemode here you can write whatever you want and after of that you just press
the enter key on your keyboard....A hudmessage will be show for some seconds with
your written word.All the terrorists must write this word on the say.If anyone player of
the terrorist team (must be alive terrorist) write it correctly then a hudmessage will be
show up with the name of the winner.

Cvars

wg_enabled

- 1: Enable the plugin. 0: Disable the plugin

wg_prefix

- Just set what you want to show up first on the plugin messages

wg_methodwrite

- 1: The player must write the word exactly. 0: The player can write whatever he wants,but if the choosen word is in his message then he wins....

wg_sound

- 1: Play a sound if we have winner in the wordgame. 0: Don't play ( and don't precache of course)

Changing admin access

Line 7: Change to whatever access you want

PHP Code:
#define ACCESS_TO_WORDGAME ADMIN_KICK 

Commands

say & say_team /wordgame

Installation

Like other plugins just add the wordgame.amxx file to addons/amxmodx/plugins/
then copy the name of the file with .amxx and place it to plugins.ini on you configs folder
and add the wordgame.txt to addons/amxmodx/data/lang folder

ChangeLog

Quote:
26-5-13 First Release(I don't add much things because i wanted to have
only the amxmodx include,but if you want something just request it here down)
Attached Files
File Type: zip WordGame.zip (10.3 KB, 279 views)
File Type: sma Get Plugin or Get Source (wordgame.sma - 931 views - 4.4 KB)
File Type: txt wordgame.txt (564 Bytes, 309 views)
__________________
.:My Plugins:.
WordGame

If you want anything add me to skype: hlias.zaxos or on steam Larisaios

Last edited by hLiaS; 05-26-2013 at 07:16.
hLiaS is offline
Send a message via Skype™ to hLiaS
oxygen935
Veteran Member
Join Date: Jun 2012
Location: Athens, Greece
Old 05-26-2013 , 12:07   Re: WordGame
Reply With Quote #2

God damn it, that is cool!
Nice work lari! GJ

EDIT:
Make this
Code:
if(!is_admin[id] && get_user_team(id) != 2)
to this
Code:
if(get_user_flags(id) & ACCESS_TO_WORDGAME || get_user_team(id) == 2) else if(get_user_team(id) != 2) else....

i think you don't need a boolean for flag check...
__________________
Quote:
Originally Posted by quark View Post
You're a genius
Stopped any pawn work cause of university for computer science

Last edited by oxygen935; 05-26-2013 at 12:47.
oxygen935 is offline
Send a message via Skype™ to oxygen935
hLiaS
Senior Member
Join Date: Aug 2011
Location: In My Holly Dreams
Old 05-26-2013 , 13:00   Re: WordGame
Reply With Quote #3

Quote:
Originally Posted by oxygen935 View Post
God damn it, that is cool!
Nice work lari! GJ

EDIT:
Make this
Code:
if(!is_admin[id] && get_user_team(id) != 2)
to this
Code:
if(get_user_flags(id) & ACCESS_TO_WORDGAME || get_user_team(id) == 2) else if(get_user_team(id) != 2) else....

i think you don't need a boolean for flag check...
I do it fore later purpose something like native
__________________
.:My Plugins:.
WordGame

If you want anything add me to skype: hlias.zaxos or on steam Larisaios
hLiaS is offline
Send a message via Skype™ to hLiaS
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 09-20-2015 , 14:07   Re: WordGame
Reply With Quote #4

You can start with this:

1.
PHP Code:
if(get_pcvar_num(g_sound) == 1
you do this cvar check in precache. At the point when precache is called custom cfg files were not executed(for example amxx.cfg), and this could be an issue in some situations(like when someone firstly install the plugin, put a different cvar value in amxx.cfg or change the cvar value from a cfg file). You can also encouter problems when cvar is changed on the fly(for example with amx_cvar command). Let's say it's default 0(so precache_sound is not called), then it's changed to 1 in game. The sound should be played, but it's not precached. Your best bet is to probably precache always the sound. Then just check if cvar is 1 when you should play it. Or, you can cache the cvar in precache(and use this value), but that means it can't be changed directly(a restart would be needed) and is the same issues with cfg file. Doesn't really matter what you choose, the important part is to have the sound always ready to be played.
2.is_admin[id] = true I would not cache this. What if I change my name and I won't have any longer admin or I get removed and amx_reloadadmins is used ? Plugin will still think I am admin. Just do the get_user_flags check when you need it.
3.if(!is_admin[id] && get_user_team(id) != 2) if this check is met just return so you won't have to write again the condition, or use else, that why it exists.
4.Don't make private functions public. public is to be used when the function will be called from outside of your plugin, like a task/menu handler etc. Here is not the case. So remove public from choosen_word.
5.In handle_say move the is_user_alive alive check in the first condition and use only else. Your conditions can be wrote as:
PHP Code:
if(equal(Arg,choosenword[id])
        {
            if(!
is_user_alive(id) || get_user_team(id) != 1)
            {
                
client_print(idprint_chat"%L"id"WG_ONLYALIVETERRORIST"prefix)
            }
            else 
            {
                
//everything is fine, right word, is alive, is tero
            
}
        }
        else 
        {
            
client_print(idprint_chat"%L"id"WG_DONTWROTECORRECTLY"prefix)
        } 
6.As I said above, else exists for a reason, if g_methodwrite is not 1 else is enough.
7.Basically, handle_say needs to be rethinked to avoid duplicated code. Firstly check the input method, then decide how you will make the check, then do the other checks like team, alive etc.

I'm quite tired now, but does this really works ? From what I see you save in choosenword the word choosed by the ct/admin. Then in handle_say you check if the user message is the same as choosenword[id], but this will be always false if another player than the word owner write the message(because it's empty). choosenword should not be a 33 cell array, using only choosenword[32] is enough, then simply check against choosenword.

Also make sure that wordmaster is not trying to type the message, it would be an unfair advantage IMO.
__________________

Last edited by HamletEagle; 09-21-2015 at 09:48.
HamletEagle is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 09-20-2015 , 15:16   Re: WordGame
Reply With Quote #5

Quote:
Originally Posted by HamletEagle View Post
1.
PHP Code:
if(get_pcvar_num(g_sound) == 1
checking this in precache right after setting the cvar is useless, the value won't change. What you can do is to register the cvar in init and check in plugin_cfg, that way custom cfg files would be loaded thus this cvar having some sense.
plugin_precache() is called before both plugin_init() and plugin_cfg() so cvars used in this function must also be registered in this function.

Registering a cvar does NOT necessarily set a cvar value. The only time the value will be set by register_cvar() is if the cvar does not yet exist (e.g. on server boot-up). This is why customized cvar values retain their non-default value on mapchange (which is expected behavior).

Also, the value of the wg_sound cvar should be precached so that it can't be changed during the map. If it gets changed from 0 to 1, nobody will have the sound precached because it wasn't set to precache when the map started. Alternatively, the sound file can be precached always and let the cvar decide whether or not to play the sound. In this case, the alternative would probably be better since you only have one sound. The alternative approach would also allow you to register the cvar in plugin_init() like normal.

Quote:
Originally Posted by HamletEagle View Post
4.Don't make private functions public. public is to be used when the function will be called from outside of your plugin referenced by name in a string, like a set_task/menu handler etc. Here is not the case. So remove public from choosen_word.
Fixed.

Quote:
Originally Posted by HamletEagle View Post
6.Since you are using get_pcvar_num(g_methodwrite two times cache this.
This shouldn't be used more than once at all. If is is being used as an "on/off" cvar, it should only be used once in an if()/else structure. If the cvar is being used for multiple different values (e.g. 1, 2, 3, etc.) then it should be used in a switch().
__________________
fysiks is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 09-20-2015 , 15:48   Re: WordGame
Reply With Quote #6

1.I am aware of the order of calls, don't worry. What I was mean is to completly remove the check(and optionally the registering), to register in init then retrieve values in cfg. So, for example if someone use amxx.cfg to change the cvar the modification would be taken into account. My point is accounting changes from cfg files, which are not loaded at the moment when precache is executed.
2.What I said it's easier to understand for people, and it's not by any means wrong.
3.Yes, could be just one if/else. He needs to put the condition in a logical order, that just escaped.

Edit: Guess I'll edit my post to make it more clear at point 1, maybe someone misunderstand.
__________________

Last edited by HamletEagle; 09-21-2015 at 09:43.
HamletEagle is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 10-09-2015 , 12:08   Re: WordGame
Reply With Quote #7

More than 15 days have passed and I don't see any changes from the author. Since section needs to be cleaned I'll unapprove this for now, but don't worry, your plugin can be reviewed at any time. PM a plugin approver after you made the changes.
__________________
HamletEagle 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 22:47.


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