Log in

View Full Version : cod2 get cvar from client



Miri
21st May 2019, 18:01
Hi all,

I'm trying to read some cvar on the client from the server.

As of now i'm able to read the name thanks to get_userinfo( "name" ); but all other things give me an UNDEFINED why is that?

My ultimate goal is to create custom cvar on the client and read them later.

maxdamage99
22nd May 2019, 13:33
My ultimate goal is to create custom cvar on the client and read them later.

WHAT FOR?)

People so stupidly disguise their fraudulent intentions...

voron00
22nd May 2019, 17:09
It's possible, however with a little trick that code allows to get player's cd-key and proably shouldn't be posted here.

Miri
22nd May 2019, 17:11
WHAT FOR?)

People so stupidly disguise their fraudulent intentions...

Sorry I didn't explain it very well, no fraudulent intentions mate.

Let's say I open a contest blue team vs red team and in 10 days I announce the winning team.
Everyone can choose(and change later) a team and every kill gets +1 to the team you cheer for (doesn't matter if you allies or axis), so you set yourself a custom cvar team_name "red" or "blue", but the server has to be able to read this cvar in some way from client.
For now i have done different working approach but i don't like them very much:
- set the team you cheer for in your name; every kill read get_userinfo( "name" ); then parse if there is team name inside and give +1;
- after connect write the team you cheer for in chat with some flag to make parsing easy, then associate team cheer with GetEntityNumber(); and track kills by that entity number, but you still need to parse every chat message.

I wanted to do something like client add cvar team_name "color" in his autoexec.cfg so is set at game launch and can change it when he wants.

In older posts it was only written that it can be done is some way but not how, that's why I'm asking.


It's possible, however with a little trick that code allows to get player's cd-key and proably shouldn't be posted here.

There isn't some neutered function where I can read only that cvar without leaking player cd-keys?

Or do you think I can execute it without a cvar but still make it already available on next connection?

voron00
22nd May 2019, 17:27
Your best option is to create a login system and store whatever data you want to associate with login in mysql/sqlite databases. https://killtube.org/showthread.php?1750-Saving-a-variable-client-side-(persistently)

Miri
22nd May 2019, 17:37
Your best option is to create a login system and store whatever data you want to associate with login in mysql/sqlite databases. https://killtube.org/showthread.php?1750-Saving-a-variable-client-side-(persistently)

I already read that thread but he said that it was still not secure at some point so i thought he never made it secure. I'll give it another read.

As for mysql the client can't change team without being logged in the server, maybe with some external web interface just for that, I'll think about it.

Thank you anyway.

maxdamage99
23rd May 2019, 06:44
Everything you want to do can be realized without "getcvar", voron00 is right: easiest way to make a user system (login/register)

IzNoGoD
24th May 2019, 20:13
The system I wrote is not 100% secure, but nothing will be 100% secure, as cod doesnt support client-side crypto.

For all normal intents and purposes the system is secure enough.

Miri
27th May 2019, 00:50
After a bit of trial and error the system works great! I just need some little QoL changes like a nice HUD and it's pretty much done!

If I have new questions can I post them here o should I create a new thread?