AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Save using steamid (https://forums.alliedmods.net/showthread.php?t=56058)

bwgrubbs1 06-05-2007 17:45

Save using steamid
 
Is there anyway to save into a nVault using steamid, or do you have to use ip ?

slmclarengt 06-05-2007 18:33

Re: Save using steamid
 
Quote:

Originally Posted by bwgrubbs1 (Post 486072)
Is there anyway to save into a nVault using steamid, or do you have to use ip ?

get_user_authid ( index, authid[], len )
then call
nvault_set or nvault_pset with the value you want to inscribe...

I don't know if I understand your question so my apologies if not.

Slmclarengt

bwgrubbs1 06-05-2007 23:26

Re: Save using steamid
 
Well, i guess, I have this function when someone comes into server.
Code:
public client_putinserver(id) {   //blah blah other stuff   // then this     load_points(id) }
here is my load points function.
Code:
public load_points(id) {     new vault = nvault_open("points")         if(vault == INVALID_HANDLE)         set_fail_state("nVault returned invalid handle")         new key[100], ip[33]         get_user_ip(id, ip, 32, 1);         formatex(key, 99,"%s-points", ip)         points[id] = nvault_get(vault, key)         nvault_close(vault)         return PLUGIN_CONTINUE; }

then on disconnect...
Code:
public client_disconnect(id) {     save_points(id) }

here is the save points function
Code:
public save_points(id) {     new vault = nvault_open("points")         if(vault == INVALID_HANDLE)         set_fail_state("nVault returned invalid handle")         new key[62], value[10], ip[33]         get_user_ip(id, ip, 32, 1);         format(key, 61,"%s-points", ip)     format(value, 9,"%d", points[id])         nvault_set(vault, key, value)     nvault_close(vault)             return PLUGIN_CONTINUE; }

SO...how would i change this to save using authid ?

bwgrubbs1 06-06-2007 05:32

Re: Save using steamid
 
or is there a better way to save, instead of using nVault ? Is SQL better ?

slmclarengt 06-06-2007 12:42

Re: Save using steamid
 
Quote:

Originally Posted by bwgrubbs1 (Post 486235)
or is there a better way to save, instead of using nVault ? Is SQL better ?

IMHO, I like SQL a lot better because it is much faster to process large amounts of data especially. Nvault is slow IMO whereas SQL is very optimized. Also, with SQLx, SQLlite, and DBI all available, you might as well give it a try because they are more powerful than NVault. However, if you are just saving a little information, it probably won't be worth using SQL to retrieve/save little bits of data.

Slmclarengt

bwgrubbs1 06-06-2007 13:20

Re: Save using steamid
 
ok...i will stick with nVault then, its not a lot of data just numbers for people...back to the whole saving with steam ID then...can i do that in nVault and how do I modify the code above to save in nVault with Steam ID ?

slmclarengt 06-06-2007 15:13

Re: Save using steamid
 
Quote:

Originally Posted by bwgrubbs1 (Post 486353)
ok...i will stick with nVault then, its not a lot of data just numbers for people...back to the whole saving with steam ID then...can i do that in nVault and how do I modify the code above to save in nVault with Steam ID ?

Code:
public client_putinserver(id) {   //blah blah other stuff   // then this     load_points(id) }
here is my load points function.
Code:
public load_points(id) {     new vault = nvault_open("points")         if(vault == INVALID_HANDLE)         set_fail_state("nVault returned invalid handle")         //new key[100], ip[33]     new key[100], authid[33] // for saving by authid/steamid     //get_user_ip(id, ip, 32, 1);     get_user_authid(id, authid, 32)         //formatex(key, 99,"%s-points", ip)     formatex(key, 99,"%s-points", authid)     points[id] = nvault_get(vault, key)         nvault_close(vault)         return PLUGIN_CONTINUE; }

then on disconnect...
Code:
public client_disconnect(id) {     save_points(id) }

here is the save points function
Code:
public save_points(id) {     new vault = nvault_open("points")         if(vault == INVALID_HANDLE)         set_fail_state("nVault returned invalid handle")         //new key[62], value[10], ip[33]     new key[62], value[10], authid[33]         //get_user_ip(id, ip, 32, 1);     get_user_authid(id, authid, 32)         //format(key, 61,"%s-points", ip)     format(key, 61,"%s-points", authid)     format(value, 9,"%d", points[id])         nvault_set(vault, key, value)     nvault_close(vault)             return PLUGIN_CONTINUE; }

There you are - I commented out the old code exactly as it was and added in the authid/steamid code to replace it to save by authid/steamid rather than IP address.

Slmclarengt

bwgrubbs1 06-06-2007 15:38

Re: Save using steamid
 
Ok, I thought i tried this before...but there is one thing that confuses me, should i put load_points(id) in client_putinserver() or in client_authorized() because when the client is put in server, are they already authorized, or is there a chance of their authid being STEAM_ID_PENDING ?

YamiKaitou 06-06-2007 15:54

Re: Save using steamid
 
client_authorized is called once the client has been authorized with Steam. This is typically right after connect, but it is able to happen at anytime. Clients can be placed into the server without being authorized.

bwgrubbs1 06-06-2007 16:12

Re: Save using steamid
 
ok, thanks, it worked for me, i moved the load_points(id) to client_authorized, and it works great !


All times are GMT -4. The time now is 10:33.

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