Raised This Month: $ Target: $400
 0% 

"Client cvars"


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Obbin
Senior Member
Join Date: Mar 2005
Location: 192.168.1.3
Old 07-24-2006 , 06:20   "Client cvars"
Reply With Quote #1

I would like to implement something like client cvars for my plugins!
I would like to create my own register_clcvar dynamic native!
I'd allso like to implement get/set_clcvar_string/num/float(id, cvar, string/num/float)

I'd like some help to start out!
The question is, how am I gonna store the value at the client?
If it's not possible to store the values at the client I'll do it in vault or SQL

Thanks!
__________________
Sig(h)!
Obbin is offline
Orangutanz
Veteran Member
Join Date: Apr 2006
Old 07-24-2006 , 06:34   Re: "Client cvars"
Reply With Quote #2

sorry something went wrong here :S

Last edited by Orangutanz; 07-24-2006 at 06:40.
Orangutanz is offline
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 07-24-2006 , 06:39   Re: "Client cvars"
Reply With Quote #3

Quote:
Originally Posted by Obbin
I would like to implement something like client cvars for my plugins!
I would like to create my own register_clcvar dynamic native!
I'd allso like to implement get/set_clcvar_string/num/float(id, cvar, string/num/float)

I'd like some help to start out!
The question is, how am I gonna store the value at the client?
If it's not possible to store the values at the client I'll do it in vault or SQL

Thanks!
Your idea about the "get/set_clcvar_string" is kinda stupid, we already have query_client_cvar as well as client_cmd.

Here's an example:

Code:
#include <amxmodx> #include <amxmisc> public plugin_init() {     register_plugin("Query Client Cvar Example","1.0","Hawk552")         register_clcmd("test","CmdTest",ADMIN_KICK,"- executes query_client_cvar test") } public CmdTest(id,level,cid) {     if(!cmd_access(id,level,cid,1))         return PLUGIN_HANDLED         query_client_cvar(id,"cl_crosshaircolor","HandleCrosshairColor")         return PLUGIN_HANDLED } public HandleCrosshairColor(id,const Cvar[],const Value[])     client_print(id,print_chat,"The cvar queried is %s and the value is %s",Cvar,Value)

Also, it's not a good idea to store a value on the client, as it can be changed by them. If you really have to though, you can use the info buffer (set_user_info/get_user_info). I'm not sure about this, I think if you add a * to the key name then only the server can change it (i.e. set_user_info(id,"*mykey","myvalue"))
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
Orangutanz
Veteran Member
Join Date: Apr 2006
Old 07-24-2006 , 06:39   Re: "Client cvars"
Reply With Quote #4

Code:
/* Registers function which will be called from client console. */ native register_clcmd(const client_cmd[],const function[],flags=-1, info[]="");

Example:
Code:
#include <amxmodx> #include <amxmisc> public plugin_init() {     register_plugin("Plugin", "Version", "Author")     register_clcmd("mycommand", "myfunction") } public myfunction(id) {     new arg1[32], arg2[32]     read_argv(1, arg1, 31)     read_argv(2, arg2, 31)         new value = str_to_num(arg1)     client_print(0, print_chat, "ID: %i called value: %i and string: %s", id, value, arg2)     return PLUGIN_HANDLED }
Storing values you could use set_user_info:
set_user_info(id, "_your_key", "value")

To retrieve:
new key[32]
get_user_info(id, "_your_key", key, 31)
Orangutanz is offline
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 07-24-2006 , 06:44   Re: "Client cvars"
Reply With Quote #5

sup Orangutanz
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
Obbin
Senior Member
Join Date: Mar 2005
Location: 192.168.1.3
Old 07-24-2006 , 11:23   Re: "Client cvars"
Reply With Quote #6

I mean totally new cvars?
Like amx_customcvar and every client could set their own value, and if they go to another server with the plugin, that server can get the cvar from the client!
Is it possible to have custom cvars on client allready?

Edit: Ah smart, I'll use that, and the point is, clients may change it !
__________________
Sig(h)!

Last edited by Obbin; 07-24-2006 at 11:26.
Obbin 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 23:20.


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