Post: [Script/Release] SetClientDvar & GetClientDvar for saving client strings and integers
05-09-2016, 03:50 PM #1
Im_YouViolateMe
NextGenUpdate Elite
(adsbygoogle = window.adsbygoogle || []).push({});
YouViolateMe




So yeah guys, here I am again with some custom scripts. Basically I'm not going to go into too much detail because there's really not a whole lot you need to know. In BO2 there is no SetClientDvar or GetClientDvar functionality, so setting dvars for clients was impossible right? Well that's not entirely the case anymore. These two functions allow you to save integers and strings for clients and retrieve them even after the game has ended. It's pretty simple. Let's say we were using this for verification. I would call SetClientDvar to a dvar named "rdc_Verified" with "Verified" as the value and it would save to a dvar with the client's name and value. The format would be name=value; The values are saved in a custom dvar. The dvar string is then split up in GetClientDvar and each value is matched up with the client's name you want to retrieve the value for. The client would then have Verified status upon returning to the match. This could also be used for saving client's menu positioning or anything else that you want the client to be able to save. To clear this up for you, no this is NOT for setting host-only dvars on clients. This is for saving variables for clients!

I've also included 2 extra functions StringContains and getIndexOf (both required). If you know C#, you'll be familiar with what these 2 functions do.


One thing to mention is that I don't know how much data the dvar's can hold!
Also be sure NOT to thread the function! This could cause unwanted results!

Source:
You must login or register to view this content.

There's really no credits needed, as these functions were written by me. So yeah, enjoy.
(adsbygoogle = window.adsbygoogle || []).push({});

The following 11 users say thank you to Im_YouViolateMe for this useful post:

/SneakerStreet/, BlueeHasSwag, codybenti, DF_AUS, DoraTheKiller97, HiddenHour, iRnZ, oCmKs_4_LiFe, Patrick, S63, xTiibo Modz
05-09-2016, 03:53 PM #2
Patrick
League Champion
Good shit man!

The following user thanked Patrick for this useful post:

Im_YouViolateMe
05-09-2016, 04:35 PM #3
Hmm. Quite handy.. I wonder.. Nice release dude

The following user thanked ProjectSynergy for this useful post:

Im_YouViolateMe
05-09-2016, 07:53 PM #4
anthonything
Space Ninja
I made a similar method in Iconic, and the dvars can hold a shit load of data. Dont worry about that lol. Nice though.

The following user thanked anthonything for this useful post:

Im_YouViolateMe
05-09-2016, 09:19 PM #5
DoraTheKiller97
Treasure hunter
Very very good. <3
05-09-2016, 09:36 PM #6
SC58
Former Staff
There is SetClientDvar but it uses dvar_cmd_t enum, so it only allows them dvars what i listed below

    
enum dvar_cmd_t
{
DVAR_CMD_AIM_LOCKON_PITCH_STRENGTH = 0x0,
DVAR_CMD_AMMO_COUNTER_HIDE = 0x1,
DVAR_CMD_CG_OBJECTIVE_TEXT = 0x2,
DVAR_CMD_COMPASS = 0x3,
DVAR_CMD_DRAW_TALK = 0x4,
DVAR_CMD_FOV = 0x5,
DVAR_CMD_HUD_HARDCORE = 0x6,
DVAR_CMD_PLAYER_SPRINT_TIME = 0x7,
DVAR_CMD_MINI_SCOREBOARD_HIDE = 0x8,
DVAR_CMD_NUM_LIVES = 0x9,
DVAR_CMD_PLAYER_PUSH_AMOUNT = 0xA,
DVAR_CMD_PLAYER_STEP_ON_ACTORS = 0xB,
DVAR_CMD_SCRIPT_MAIN_MENU = 0xC,
DVAR_CMD_THIRD_PERSON = 0xD,
DVAR_CMD_THIRD_PERSON_ANGLE = 0xE,
DVAR_CMD_COUNT = 0xF,
};


    
GSC Function + The dvar it uses:

SetClientAimLockonPitchStrength - Dvar: aim_lockon_pitch_strength
SetClientAmmoCounterHide - Dvar: ammoCounterHide
SetClientCGObjectiveText = cg_t->objectiveText
SetClientCompass - Dvar: compass
SetClientDrawTalk - Dvar: cg_drawTalk
SetClientFOV - Dvar: cg_fov
SetClientHUDHardcore - Dvar: ui_hud_hardcore
SetClientPlayerSprintTime - Dvar: player_sprintTime
SetClientMiniScoreboardHide - Dvar: miniscoreboardhide
SetClientNumLives - Dvar: scr_numLives
SetClientPlayerPushAmount - Dvar: playerPushAmount
SetClientScriptMainMenu = cg_t->scriptMainMenu
SetClientThirdPersonAngle - Dvar: cg_thirdPersonAngle


You can't edit anywhere in the elf for a client to be able to use any dvar, the SV_GameSendServerCommand function command index get sent to each client for whatever and when they get it it logs into CG_DeployServerCommand where the command is selected plus the args its using to execute CG_SetClientDvarFromServer where there it execute the local set dvar function to change the value, unlike other cods it has it where u can use any dvar, but bo2 made it so u can only change a few client dvars

if you want to edit this it would only work for urself or if the other client has the mod aswell but there is no point of even doing this

The following 4 users say thank you to SC58 for this useful post:

DoraTheKiller97, Im_YouViolateMe, MemoryPointers, ProjectSynergy
05-09-2016, 11:27 PM #7
DoraTheKiller97
Treasure hunter
You need the GetName function which isnt posted here..???
05-09-2016, 11:36 PM #8
Originally posted by dorathekiller97 View Post
You need the GetName function which isnt posted here..???


    
getPlayerName(player)
{
playerName = getSubStr(player.name, 0, player.name.size);
for(i = 0; i < playerName.size; i++)
{
if(playerName[i] == "]")
break;
}
if(playerName.size != i)
playerName = getSubStr(playerName, i + 1, playerName.size);

return playerName;
}
05-09-2016, 11:39 PM #9
Originally posted by YouViolateMe View Post
YouViolateMe




So yeah guys, here I am again with some custom scripts. Basically I'm not going to go into too much detail because there's really not a whole lot you need to know. In BO2 there is no SetClientDvar or GetClientDvar functionality, so setting dvars for clients was impossible right? Well that's not entirely the case anymore. These two functions allow you to save integers and strings for clients and retrieve them even after the game has ended. It's pretty simple. Let's say we were using this for verification. I would call SetClientDvar to a dvar named "rdc_Verified" with "Verified" as the value and it would save to a dvar with the client's name and value. The format would be name=value; The values are saved in a custom dvar. The dvar string is then split up in GetClientDvar and each value is matched up with the client's name you want to retrieve the value for. The client would then have Verified status upon returning to the match. This could also be used for saving client's menu positioning or anything else that you want the client to be able to save. To clear this up for you, no this is NOT for setting host-only dvars on clients. This is for saving variables for clients!

I've also included 2 extra functions StringContains and getIndexOf (both required). If you know C#, you'll be familiar with what these 2 functions do.


One thing to mention is that I don't know how much data the dvar's can hold!
Also be sure NOT to thread the function! This could cause unwanted results!

Source:
You must login or register to view this content.

There's really no credits needed, as these functions were written by me. So yeah, enjoy.


Can you set actual game dvars, like fov and whatnot with this? Otherwise, I wouldn't really call it "setClientDvar"
05-09-2016, 11:47 PM #10
SC58
Former Staff
Originally posted by john
Can you set actual game dvars, like fov and whatnot with this? Otherwise, I wouldn't really call it "setClientDvar"


You must login or register to view this content.

no, this is pretty much a verification system nothing more

The following 2 users say thank you to SC58 for this useful post:

Im_YouViolateMe, John

Copyright © 2026, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo