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

Diversant


Post New Thread Reply   
 
Thread Tools Display Modes
Plugin Info:     Modification:   Counter-Strike        Category:   Gameplay       
Phant
Veteran Member
Join Date: Sep 2009
Location: New Jersey
Old 09-01-2015 , 03:02   Diversant
Reply With Quote #1

Diversant

Description:
Plugin allows Players arrange a Diversion! After next spawn (next round) Diversant player spawns on enemy (opposite) base with enemies uniform (skin).
How to deserve Diversion? Kill 5 (by default) enemies per round, or kill 13 (by default) in a row (without death).
Only one (1) player in team can do Diversion per round. Frags in Diversion not count and can not be used for new Diversion.
Original idea by War3 mod for Counter-Strike ("mole" item).
I accept remarks about language file, because my English not so good.

Console commands (ADMIN_RCON):
  • div_set "<name or #userid>"
    — set Player Diversion.
  • div_unset "<name or #userid>"
    — unset Diversion from Player (works only when Player not spawned yet as Diversant).
CVARS:
  • div_frags_pr "5"
    — how many enemies per round Player should kill for deserve Diversion. "0" — disable this feature.
  • div_frags "13"
    — how many enemies Player should kill in a row (without death) for deserve Diversion. "0" — disable this feature.
Console command:
  • say[_team] "/div"
    — take (use) Diversion.
Installation:
  1. Download and install plugin normally.
  2. Download language file and move it in "...\cstrike\addons\amxmodx\data\lang\" directory.
Thanks to:
Attached Files
File Type: txt diversant.txt (2.1 KB, 194 views)
File Type: sma Get Plugin or Get Source (Diversant.sma - 639 views - 10.3 KB)

Last edited by Phant; 09-06-2015 at 07:40.
Phant is offline
Send a message via ICQ to Phant
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 09-01-2015 , 04:43   Re: Diversant
Reply With Quote #2

  • Caching cvar is not necessary here. you have no code called very often. Use pcvar directly. It will simplify your code as well.
  • Don't forget that MAX_PLAYERS is a define in 1.8.3-dev, so you should still define it in your plugin with a check against AMXX_VERSION_NUM < 183. Unless you're targeting this plugin to be used only in dev version?
  • There is no reason to use defines for customization. Use cvars, so people won't have to recompile the plugin.
  • You're misusing LANG_PLAYER. This one should be used only when you pass 0 as index, so when internally Amxx will loop over all players, this tells Amxx to use the current player's language. If you pass a player's index directly in a native, then you should this index instead.
  • Don't use #define for string which will be repeated more than one time. String will be allocated more than one time. Use instead new const.
  • Don't make private functions public. This should be used only on callback/forward, when function needs to be called outside of the plugin.
  • Use charsmax instead of hardcoding the max length. Exemple: read_argv(1, arg, charsmax(arg)), better for maintainability.
  • is_user_connected(id) && is_user_alive(id), first is pointless, an alive player is always connected.
  • team_swap is silly, you know before the old team, you should pass the new team instead.
  • You likely don't need model_swap, you can direcly call DLLFunc_ClientUserInfoChanged, game will pickup a model and will set it.

A first bunch to start.
__________________
Arkshine is offline
Phant
Veteran Member
Join Date: Sep 2009
Location: New Jersey
Old 09-02-2015 , 06:25   Re: Diversant
Reply With Quote #3

Oh, thank you for great post .

Quote:
Caching cvar is not necessary here. you have no code called very often. Use pcvar directly. It will simplify your code as well.
It's make code more harder. For example, Player buy Diversion (waste $16000) and admin change cost (div_cost 5000). So, Player can lost their money. In this case I should write Diversion cost for every player who buy it.

Quote:
You likely don't need model_swap, you can direcly call DLLFunc_ClientUserInfoChanged, game will pickup a model and will set it.
Testet right now. I replaced "model_swap(id, CS_TEAM_CT)" to:
PHP Code:
dllfunc(DLLFunc_ClientUserInfoChangedidengfunc(EngFunc_GetInfoKeyBufferid)) 
or:
PHP Code:
dllfunc(DLLFunc_ClientUserInfoChangedid
Both don't change Player model .

Last edited by Phant; 09-02-2015 at 06:26.
Phant is offline
Send a message via ICQ to Phant
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 09-02-2015 , 07:01   Re: Diversant
Reply With Quote #4

Quote:
It's make code more harder. For example, Player buy Diversion (waste $16000) and admin change cost (div_cost 5000). So, Player can lost their money. In this case I should write Diversion cost for every player who buy it.
I've honestly no idea what your're talking about. i'm talking about instead of using get_cvar_num and caching the value in a global var 6.1 seconds later, you simply call directly get_pcvar_num directly where it's used. Never heard about cvar pointer?

Quote:
Both don't change Player model
It should be the first only and it should work, here below CS code.
You see well calling this function call SetPlayerModel. But actually it doesn't randomize (unless you set m_iModelName).

code


Well, I guess you can keep your code, not like it does really matter anyway.
You could then use an array instead of using a switch, it will make coder shorter and faster (trivial though).
__________________

Last edited by Arkshine; 09-02-2015 at 07:06.
Arkshine is offline
Phant
Veteran Member
Join Date: Sep 2009
Location: New Jersey
Old 09-05-2015 , 08:57   Re: Diversant
Reply With Quote #5

Updated! Buying feature removed!
Phant is offline
Send a message via ICQ to Phant
Old 09-06-2015, 07:42
Phant
This message has been deleted by Phant. Reason: In Scripting Help
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 09-06-2015 , 08:34   Re: Diversant
Reply With Quote #6

Well, client will set default model based on latest known team index of player. Probably client knows team based on TeamInfo message. Maybe sending manually a TeamInfo with enemy team name after setting model (or before?). But well, it will likely update Scoreboard.
__________________
Arkshine is offline
Reply


Thread Tools
Display Modes

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 03:18.


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