Raised This Month: $ Target: $400
 0% 

How can I store data? [Solved]


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Shaman
Senior Member
Join Date: Dec 2006
Location: Istanbul, Turkey
Old 12-04-2006 , 16:22   How can I store data? [Solved]
Reply With Quote #1

I am making a new plugin for Half-Life. Here's what will happen:
-Player kills another player
-Player gets x credit(s)
-Player buys items with x credit(s)
-Player uses those items

So all players items and credits will be stored but where?
I know I can use "set_localinfo" and "get_localinfo" but players can change their credits with "setinfo credits x".
I can use nVault too but I don't know how to use it.
What should I do?

(I worked with commands, events, menus, I know how to compile .sma files etc.)

Last edited by Shaman; 12-06-2006 at 16:29.
Shaman is offline
Send a message via ICQ to Shaman Send a message via AIM to Shaman Send a message via MSN to Shaman Send a message via Yahoo to Shaman
The Specialist
BANNED
Join Date: Nov 2006
Old 12-04-2006 , 17:18   Re: Storing data - Help!!!
Reply With Quote #2

or you can use the new amxmodx read and write commands. theres a tutorial in the turoail section called "how to read/write to a file " or something. go read it .

lastley , dont use help or !!!! in a scripting help tittlle no one will respond and youll be yelled at by moderators .
The Specialist is offline
Send a message via AIM to The Specialist
spunko
Senior Member
Join Date: Jun 2005
Location: Ecuador
Old 12-05-2006 , 00:18   Re: Storing data - Help!!!
Reply With Quote #3

hi.. if u want to save and load data you could use this example
PHP Code:
#include <amxmodx>
#include <vault>
 
#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "Owner"
 
public plugin_init() 
{
        
register_plugin(PLUGINVERSIONAUTHOR)
}
 
public 
client_authorized(id)
{
        
// Load data
        
LoadData(id)
}
 
SaveData(id)

 
 
/* Get steam id */
        
new authid[32]
        
get_user_authid(idauthid31)
 
        
/* Set's vault key; so we can look it up after */
        
new vaultkey[64]
 
        
/* ITEM EXAMPLE */
        
format(vaultkey63"HL_MOD_%s"authid)
 
        
/* Set's vault data; check the credits */
        
new vaultdata[64]
 
        
format(vaultdata63"%d"item[id])
 
        
/* save data to vault.ini */
        
set_vaultdata(vaultkeyvaultdata)
}
 
LoadData(id

        
/* Get steam id */
 
        
new authid[32
        
get_user_authid(id,authid,31)
 
        
/* ITEM EXAMPLE */
 
        /* Get vault key and data */
        
new vaultkey[64], vaultdata[64]
        
format(vaultkey63"HL_MOD_%s"authid
        
get_vaultdata(vaultkeyvaultdata63)
 
        
/* Set value to the player */
        
item[id] = str_to_num(vaultdata)

but that is just how to save and load data..
To save what the player buys, you can use a menu for example
PHP Code:
public itemmenu(idkey) {
 switch(
key
 {
  case 
0Item1(id)
  case 
1Item2(id)
  case 
2Item3(id)
  case 
3Item4(id)
  default: return 
PLUGIN_HANDLED
 
}
 
SaveData(id)  //save here...
 
return PLUGIN_HANDLED

__________________
spunko is offline
Send a message via MSN to spunko
p3tsin
Senior Member
Join Date: Sep 2005
Location: Finland
Old 12-05-2006 , 08:18   Re: Storing data - Help!!!
Reply With Quote #4

Quote:
Originally Posted by Shaman View Post
So all players items and credits will be stored but where?
I know I can use "set_localinfo" and "get_localinfo" but players can change their credits with "setinfo credits x".
I can use nVault too but I don't know how to use it.
What should I do?
localinfo is stored in the server and has nothing to do with get/set_user_info (setinfo),
tho it gets cleared on server shutdown making it good for only storing temporary data..
(n)vault would probably be the best choice in this case but ive never used it so cant rly help
__________________
plop
p3tsin is offline
Shaman
Senior Member
Join Date: Dec 2006
Location: Istanbul, Turkey
Old 12-05-2006 , 10:34   Re: Storing data - Help!!!
Reply With Quote #5

Thank you I will use "get_vault_data" and "set_vault_data".
Shaman is offline
Send a message via ICQ to Shaman Send a message via AIM to Shaman Send a message via MSN to Shaman Send a message via Yahoo to Shaman
The Specialist
BANNED
Join Date: Nov 2006
Old 12-05-2006 , 14:29   Re: Storing data - Help!!!
Reply With Quote #6

actually vaullt is outdated and laggy, if you want to use that type of info storing use nvualt , which is the newer better version of vualt
The Specialist is offline
Send a message via AIM to The Specialist
Shaman
Senior Member
Join Date: Dec 2006
Location: Istanbul, Turkey
Old 12-06-2006 , 11:37   Re: Storing data - Help!!!
Reply With Quote #7

Where can I get/enable nvault?
Shaman is offline
Send a message via ICQ to Shaman Send a message via AIM to Shaman Send a message via MSN to Shaman Send a message via Yahoo to Shaman
The Specialist
BANNED
Join Date: Nov 2006
Old 12-06-2006 , 13:23   Re: Storing data - Help!!!
Reply With Quote #8

#include <nvualt>

www.amxmodx.org/doc theres some commands for it there

Heres the direct link
http://www.amxmodx.org/doc/source/fu...ault/index.htm

Last edited by The Specialist; 12-06-2006 at 16:31.
The Specialist is offline
Send a message via AIM to The Specialist
Shaman
Senior Member
Join Date: Dec 2006
Location: Istanbul, Turkey
Old 12-06-2006 , 16:27   Re: Storing data - Help!!!
Reply With Quote #9

Thank you, thank you very much!!! It's working
Shaman is offline
Send a message via ICQ to Shaman Send a message via AIM to Shaman Send a message via MSN to Shaman Send a message via Yahoo to Shaman
The Specialist
BANNED
Join Date: Nov 2006
Old 12-06-2006 , 16:29   Re: Storing data - Help!!!
Reply With Quote #10

Np , its what i do
The Specialist is offline
Send a message via AIM to The Specialist
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 06:49.


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