AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Get cvar value and set it to other cvar value + number (https://forums.alliedmods.net/showthread.php?t=62098)

mordi 10-18-2007 16:36

Get cvar value and set it to other cvar value + number
 
OK, very short:

What I need to do is to get two client's (or server) cvar values (A and B) and set cvar A to: cvar B + a number. This must be possible in some kind of way! :|

M249-M4A1 10-18-2007 16:51

Re: Get cvar value and set it to other cvar value + number
 
Server CVARs:
PHP Code:

new not_a_random_number 100
    set_cvar_num
("cvar_a"get_cvar_num("cvar_b") + not_a_random_number


_Master_ 10-19-2007 03:29

Re: Get cvar value and set it to other cvar value + number
 
Check if the cvars are server-side or not ( get_cvar_pointer() will fail if server cvar does not exists )

mordi 10-19-2007 05:49

Re: Get cvar value and set it to other cvar value + number
 
How would I do for the client cmd's then? That's the most important thing..

_Master_ 10-19-2007 05:53

Re: Get cvar value and set it to other cvar value + number
 
I do believe you mean "client cvars"...
Read this

Also I would like to make some clarifications regarding my previos post:
If the cvar is NOT server-side then it may or may not be client-side. Having said this you would have to make sure that the cvar you're testing exists either server or client-side.

mordi 10-19-2007 06:01

Re: Get cvar value and set it to other cvar value + number
 
I know! Already read that, the point is to get some cvar and add a number to it and set another cvar to the other with the number (hard to read, that's why I used A & B as examples on first post)

_Master_ 10-19-2007 06:21

Re: Get cvar value and set it to other cvar value + number
 
1. Get cvar values
2. If cvar to set is server-side then do a set_pcvar_*() - this would work because get_cvar_pointer did not fail. If the cvar is client-side then do a client_cmd( id, "%s %X", cvar_name, new_cvar_value )


All times are GMT -4. The time now is 01:16.

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