Raised This Month: $ Target: $400
 0% 

Save using steamid


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
bwgrubbs1
Senior Member
Join Date: Sep 2006
Old 06-05-2007 , 17:45   Save using steamid
Reply With Quote #1

Is there anyway to save into a nVault using steamid, or do you have to use ip ?
bwgrubbs1 is offline
slmclarengt
Veteran Member
Join Date: Jul 2004
Location: The Cookie Jar... or Pul
Old 06-05-2007 , 18:33   Re: Save using steamid
Reply With Quote #2

Quote:
Originally Posted by bwgrubbs1 View Post
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
__________________
But we don’t beat the Reaper by living longer. We beat the Reaper by living well. -Dr. Randy Pausch, R.I.P.

Come play WC3:FT on BnD Clan Server! You know you want to: Connect to WC3:FT BnD - go ahead click me!
slmclarengt is offline
bwgrubbs1
Senior Member
Join Date: Sep 2006
Old 06-05-2007 , 23:26   Re: Save using steamid
Reply With Quote #3

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 is offline
bwgrubbs1
Senior Member
Join Date: Sep 2006
Old 06-06-2007 , 05:32   Re: Save using steamid
Reply With Quote #4

or is there a better way to save, instead of using nVault ? Is SQL better ?
bwgrubbs1 is offline
slmclarengt
Veteran Member
Join Date: Jul 2004
Location: The Cookie Jar... or Pul
Old 06-06-2007 , 12:42   Re: Save using steamid
Reply With Quote #5

Quote:
Originally Posted by bwgrubbs1 View Post
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
__________________
But we don’t beat the Reaper by living longer. We beat the Reaper by living well. -Dr. Randy Pausch, R.I.P.

Come play WC3:FT on BnD Clan Server! You know you want to: Connect to WC3:FT BnD - go ahead click me!
slmclarengt is offline
bwgrubbs1
Senior Member
Join Date: Sep 2006
Old 06-06-2007 , 13:20   Re: Save using steamid
Reply With Quote #6

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 ?
bwgrubbs1 is offline
slmclarengt
Veteran Member
Join Date: Jul 2004
Location: The Cookie Jar... or Pul
Old 06-06-2007 , 15:13   Re: Save using steamid
Reply With Quote #7

Quote:
Originally Posted by bwgrubbs1 View Post
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
__________________
But we don’t beat the Reaper by living longer. We beat the Reaper by living well. -Dr. Randy Pausch, R.I.P.

Come play WC3:FT on BnD Clan Server! You know you want to: Connect to WC3:FT BnD - go ahead click me!
slmclarengt is offline
bwgrubbs1
Senior Member
Join Date: Sep 2006
Old 06-06-2007 , 15:38   Re: Save using steamid
Reply With Quote #8

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 ?
bwgrubbs1 is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 06-06-2007 , 15:54   Re: Save using steamid
Reply With Quote #9

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.
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
bwgrubbs1
Senior Member
Join Date: Sep 2006
Old 06-06-2007 , 16:12   Re: Save using steamid
Reply With Quote #10

ok, thanks, it worked for me, i moved the load_points(id) to client_authorized, and it works great !
bwgrubbs1 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 10:33.


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