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

[Metamod] In-/decrease cvar value depending on the player count


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Rirre
Veteran Member
Join Date: Nov 2006
Old 08-20-2014 , 08:05   [Metamod] In-/decrease cvar value depending on the player count
Reply With Quote #1

I'm lost with this so I need to ask for help.
So what I'm trying to do/want to do is to increase the cvar "sk_dmg" when more than 1 (> 1) player/client connect and decrease on disconnect, by 10% each.
It should always be the default value (20) when it's just 1 client on the server or empty.
Code:
cvar_t  sk_dmg = {"sk_dmg","20"}; void mmClientConnect( edict_t *pEntity ) {     // check for a proxy/hltv     if ( ( pEntity->v.flags & FL_PROXY ) )         RETURN_META(MRES_SUPERCEDE);     int i = ENTINDEX(pEntity)-1;     if ((i >= 0) && (i < 32))     {         // balance sk_dmg after player count...         CVAR_SET_FLOAT( "sk_dmg", ... ); // increase 10%     }     RETURN_META(MRES_IGNORED); } void mmClientDisconnect( edict_t *pEntity ) {     // check for a proxy/hltv     if ( ( pEntity->v.flags & FL_PROXY ) )         RETURN_META(MRES_SUPERCEDE);     int i = ENTINDEX(pEntity)-1;     if ((i >= 0) && (i < 32))     {         // balance sk_dmg after player count...         CVAR_SET_FLOAT( "sk_dmg", ... ); // decrease 10%     }     RETURN_META(MRES_IGNORED); }
Rirre is offline
claudiuhks
Yam Inside®™℠
Join Date: Jan 2010
Location: Living Randomly
Old 08-20-2014 , 08:34   Re: [Metamod] In-/decrease cvar value depending on the player count
Reply With Quote #2

PHP Code:
void clientputinserver()
 
cvar++

void clientdisconnect()
 
cvar--

void serverdeactivate()
 
cvar=
Do not supercede.
__________________

Last edited by claudiuhks; 08-20-2014 at 08:36.
claudiuhks is offline
Send a message via MSN to claudiuhks Send a message via Yahoo to claudiuhks Send a message via Skype™ to claudiuhks
joropito
AlliedModders Donor
Join Date: Mar 2009
Location: pfnAddToFullPack
Old 08-22-2014 , 07:42   Re: [Metamod] In-/decrease cvar value depending on the player count
Reply With Quote #3

PHP Code:
cvar_t  sk_dmg = {"sk_dmg","20"};
cvar_tp_sk_dmg = &sk_dmg
Then

PHP Code:
p_sk_dmg->value p_sk_dmg->value xxx
__________________

Divide et vinces
approved plugins | steam account

I don't accept PM for support. Just ask on forums.
If you're looking for private work, PM me.
joropito is offline
Send a message via MSN to joropito
Rirre
Veteran Member
Join Date: Nov 2006
Old 08-25-2014 , 16:30   Re: [Metamod] In-/decrease cvar value depending on the player count
Reply With Quote #4

Quote:
Originally Posted by claudiuhks View Post
PHP Code:
void clientputinserver()
 
cvar++

void clientdisconnect()
 
cvar--

void serverdeactivate()
 
cvar=
Do not supercede.
Thanks

Last edited by Rirre; 08-25-2014 at 17:03.
Rirre 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 11:51.


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