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

Module: Cvar Utilities (v1.6)


Post New Thread Reply   
 
Thread Tools Display Modes
Doc-Holiday
AlliedModders Donor
Join Date: Jul 2007
Old 02-20-2012 , 04:12   Re: Module: Cvar Utilities (v1.3.1)
Reply With Quote #81

Question when using CvarCache.. you said it updates the value without extra natives.. not sure i understand what you mean.

PHP Code:
CvarCache(register_cvar("dbd_toggle""1"), CvarType_Intg_CvarCache[g_iEnabled]); //Turns plugin on and off 
It's my listen server (new game in cz) it works checking value g_CvarCache[g_iEnabled] before doing the stuff for the plugin.

but if in my console i write dbd_toggle 0.. it doesn't update the value to the g_CvarCache[g_iEnabled] var.. Is that what you meant?

Or does that require hooking change?
Doc-Holiday is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 02-20-2012 , 04:40   Re: Module: Cvar Utilities (v1.3.1)
Reply With Quote #82

It should update. That's the very purpose of this native :p.

I've tested before releasing so I know it's working fine. Make sure you type the right cvars and you check well the value.

Show me the code, so I can test myself.
__________________

Last edited by Arkshine; 02-20-2012 at 13:20.
Arkshine is offline
yokomo
Surprise Ascot!
Join Date: May 2010
Location: Malaysia
Old 03-23-2012 , 00:41   Re: Module: Cvar Utilities (v1.3.1)
Reply With Quote #83

This module is good but sadly it not support cl_* & gl_* cvars. Any idea how to make it compatible with client cvars?

I want to lock some of client cvars.
__________________
Team-MMG CS1.6 Servers:
✅ MultiMod -- 103.179.44.152:27016
✅ Zombie Plague -- 103.179.44.152:27015
✅ Zombie Escape -- 103.179.44.152:27017
✅ Klassik Kombat -- 103.179.44.152:27018
✅ Boss-Battle -- 103.179.44.152:27019

Last edited by yokomo; 03-23-2012 at 00:41.
yokomo is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 03-23-2012 , 00:54   Re: Module: Cvar Utilities (v1.3.1)
Reply With Quote #84

Client cvars and a server cvars are not the same thing.
Server is not informed when a client cvar is changed, so your problem is not related to that thread at all and should belong to scripting help or suggestions/requests forum
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 03-23-2012 at 00:55.
ConnorMcLeod is offline
Doc-Holiday
AlliedModders Donor
Join Date: Jul 2007
Old 03-23-2012 , 00:57   Re: Module: Cvar Utilities (v1.3.1)
Reply With Quote #85

Quote:
Originally Posted by Arkshine View Post
It should update. That's the very purpose of this native :p.

I've tested before releasing so I know it's working fine. Make sure you type the right cvars and you check well the value.

Show me the code, so I can test myself.
Do i need to hook the change of the variables or should it update the cvars automatically
Doc-Holiday is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 03-23-2012 , 03:48   Re: Module: Cvar Utilities (v1.3.1)
Reply With Quote #86

May be you could try without the array thing :

g_CvarCache[g_iEnabled]

->

g_CvarCache_iEnabled
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 03-23-2012 , 05:50   Re: Module: Cvar Utilities (v1.3.1)
Reply With Quote #87

With array it works too, I've tested and put also an example.
__________________
Arkshine is offline
K.K.Lv
Veteran Member
Join Date: Aug 2008
Location: GameFolder
Old 05-10-2012 , 03:39   Re: Module: Cvar Utilities (v1.3.1)
Reply With Quote #88

what happen with this code ?
Code:
public CvarHookChanged(handleCvar, const oldValue[], const newValue[], const cvarName[]) {     server_print("name:%s--Old:%s--New:%s", cvarName, oldValue, newValue);     if (strcmp(cvarName, "sv_password") == 0)     {         client_print(0, print_chat, "the sv_password has been changed to : %s", newValue[0] ? newValue : "NULL");     } }

or Is there anything I did wrong ?
the server console print :
Code:
name:amx_timeleft--Old:sv_password--New:19:58
name:amx_timeleft--Old:sv_password--New:19:57
Connection to Steam servers successful.
   VAC secure mode disabled.
name:amx_timeleft--Old:sv_password--New:19:56
name:amx_timeleft--Old:sv_password--New:19:55
name:amx_timeleft--Old:sv_password--New:19:54
name:amx_timeleft--Old:sv_password--New:19:54
name:amx_timeleft--Old:sv_password--New:19:53
name:amx_timeleft--Old:sv_password--New:19:52
name:amx_timeleft--Old:sv_password--New:19:51
name:amx_timeleft--Old:sv_password--New:19:50
name:amx_timeleft--Old:sv_password--New:19:50
__________________
QQ:116268742
K.K.Lv is offline
Send a message via MSN to K.K.Lv
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 05-10-2012 , 05:42   Re: Module: Cvar Utilities (v1.3.1)
Reply With Quote #89

No, it's fine, just an AMXX issue related to the string buffer. The buffer for string operation is very poorly implemented in AMXX. Here, when you call strcmp, the string "sv_password" is copied in the first buffer, this one used previously to hold the old value for the forward..

As solution, use equal, it does not use buffer, it loops directly.
__________________

Last edited by Arkshine; 05-10-2012 at 06:53.
Arkshine is offline
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 08-30-2012 , 07:58   Re: Module: Cvar Utilities (v1.3.1)
Reply With Quote #90

Well, nice work on the module Arkhsine. I just made a plugin based on this module but something it's really strange. The following events occur with the fix plugin placed before admincmd.amxx

Console output:
Code:
] amx_cvar amx_immunity 1
[AMXX] Cvar "amx_immunity" changed to "a"
] amx_cvar amx_immunity 0
[AMXX] Cvar "amx_immunity" changed to "a"
Debug(): a -> 1
ADMIN Alka:  set cvar amx_immunity to "a"
Debug(): a -> 0
ADMIN Alka:  set cvar amx_immunity
Plugin:
PHP Code:

#include <amxmodx>
#include <cvar_util>

#define PLUGIN "Admin Immunity"
#define VERSION "1.0"
#define AUTHOR "Alka"

new g_iMaxPlayers;

new 
bool:g_bHasImmunity[32];

new 
g_iCvarValue;

public 
plugin_init() {
    
    
register_plugin(PLUGINVERSIONAUTHOR);
    
    new 
iCvarHandle CvarRegister("amx_immunity""0", .hasMin true, .minValue 0.0, .hasMax true, .maxValue 1.0, .forceInterval true);
    
    
CvarHookChange(iCvarHandle "OnImmunityChange");
    
CvarCache(iCvarHandleCvarType_Intg_iCvarValue);
    
    
g_iMaxPlayers get_maxplayers();
}

public 
client_putinserver(id)
{
    if(
g_iCvarValue)
    {
        if(
get_user_flags(id) & read_flags("a"))
            
remove_user_flags(idread_flags("a"));
    }
}

public 
OnImmunityChange(handleCvar, const oldValue[], const newValue[], const cvarName[])
{
    
client_print(0print_chat"Debug(): %s -> %s"oldValuenewValue);
    if(
str_to_num(newValue))
    {
        for(new 
id id <= g_iMaxPlayers id++)
        {
            if(!
is_user_connected(id))
                continue;
            
            if(
get_user_flags(id) & read_flags("a"))
            {
                
g_bHasImmunity[id] = true;
                
remove_user_flags(idread_flags("a"));
            }
        }
    }
    else
    {
        for(new 
id id <= g_iMaxPlayers id++)
        {
            if(!
is_user_connected(id))
                continue;
            
            if(
g_bHasImmunity[id])
            {
                
g_bHasImmunity[id] = false;
                
set_user_flags(idget_user_flags(id) | read_flags("a"));
            }
        }
    }

Can you explain if something it's wrong or why it's behaving like this? Thank you
__________________
Still...lovin' . Connor noob! Hello

Last edited by Alka; 08-30-2012 at 08:01.
Alka 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 19:32.


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