AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How can I store data? [Solved] (https://forums.alliedmods.net/showthread.php?t=48108)

Shaman 12-04-2006 16:22

How can I store data? [Solved]
 
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.)

The Specialist 12-04-2006 17:18

Re: Storing data - Help!!!
 
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 .

spunko 12-05-2006 00:18

Re: Storing data - Help!!!
 
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



p3tsin 12-05-2006 08:18

Re: Storing data - Help!!!
 
Quote:

Originally Posted by Shaman (Post 410836)
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 :|

Shaman 12-05-2006 10:34

Re: Storing data - Help!!!
 
Thank you :up: I will use "get_vault_data" and "set_vault_data".

The Specialist 12-05-2006 14:29

Re: Storing data - Help!!!
 
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

Shaman 12-06-2006 11:37

Re: Storing data - Help!!!
 
Where can I get/enable nvault?

The Specialist 12-06-2006 13:23

Re: Storing data - Help!!!
 
#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

Shaman 12-06-2006 16:27

Re: Storing data - Help!!!
 
Thank you, thank you very much!!! It's working :mrgreen:

The Specialist 12-06-2006 16:29

Re: Storing data - Help!!!
 
Np , its what i do :mrgreen:


All times are GMT -4. The time now is 06:49.

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