Raised This Month: $ Target: $400
 0% 

Save level based on class (XP Mod)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
GXLZPGX
Veteran Member
Join Date: Sep 2009
Old 11-24-2010 , 14:03   Save level based on class (XP Mod)
Reply With Quote #1

I noticed in the XP mod tutorial by Flyeni6, it only saves their level.

PHP Code:
public SaveData(id

    
// get the players steam id. We need this because we are saving by steam id 
    
new AuthID[35get_user_authid(id,AuthID,34
    new 
vaultkey[64],vaultdata[256
    
// format wat is going to be in the animal mod vault file 
    
format(vaultkey,63,"%s-Mod",AuthID
    
format(vaultdata,255,"%i#%i#",PlayerXP[id],PlayerLevel[id]) 
    
// save the data 
    
nvault_set(g_vault,vaultkey,vaultdata
    return 
PLUGIN_CONTINUE 

So no matter what class they are, they're level will always be the same. How can I save seperate levels for each class?
__________________
Currently accepting payment US DOLLARS ONLY for custom plugins, contact me through PM.
GXLZPGX is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 11-24-2010 , 16:06   Re: Save level based on class (XP Mod)
Reply With Quote #2

Combine SteamID and the class name, then use that for the nvault key.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
GXLZPGX
Veteran Member
Join Date: Sep 2009
Old 11-24-2010 , 16:36   Re: Save level based on class (XP Mod)
Reply With Quote #3

Quote:
Originally Posted by Exolent[jNr] View Post
Combine SteamID and the class name, then use that for the nvault key.
Thanks ;)

Another thing is, there are two classes, and the first class (warriors), get two types of stats, strength and dexterity, and the second class (assassins) has agility and transparency. How would I save those seperately as well?
__________________
Currently accepting payment US DOLLARS ONLY for custom plugins, contact me through PM.
GXLZPGX is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 11-24-2010 , 16:38   Re: Save level based on class (XP Mod)
Reply With Quote #4

SteamID + class name + stat name = stat value
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
GXLZPGX
Veteran Member
Join Date: Sep 2009
Old 11-24-2010 , 16:44   Re: Save level based on class (XP Mod)
Reply With Quote #5

Quote:
Originally Posted by Exolent[jNr] View Post
SteamID + class name + stat name = stat value
Not exactly asking you to do it for me, but could you explain that a bit better? How would I configure the vault key?

PHP Code:
public Save_Data(id)
{
    new 
AuthID[35]
    
get_user_authidid,AuthID,34 
    
    new 
VaultKey[64], VaultData[256]
    
    
format(VaultKey63"%s-wva-%i-class"AuthIDpub_Class[id])
    
format(VaultData255"%i#%i#"pub_Experience[id], pub_Level[id]) 
    
    
nvault_set(g_VaultVaultKeyVaultData

__________________
Currently accepting payment US DOLLARS ONLY for custom plugins, contact me through PM.
GXLZPGX is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 11-24-2010 , 16:51   Re: Save level based on class (XP Mod)
Reply With Quote #6

Well if you're one of those people that likes to have multiple values in an nvault entry then that method is fine.
I personally like using 1 value per key so I can just use nvault_get() to return the integer.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 11-24-2010 , 17:00   Re: Save level based on class (XP Mod)
Reply With Quote #7

Here's an example of how I would've done the code in your first post.

PHP Code:
public SaveData(id

    new 
AuthID[35]
    
get_user_authid(id,AuthID,34)
    
    new 
vaultkey[64], vaultdata[11]
    
formatex(vaultkey,63,"%s-xp",AuthID)
    
num_to_str(PlayerXP[id],vaultdata,10)
    
nvault_set(g_vault,vaultkeyvaultdata)
    
    
formatex(vaultkey,63,"%s-level",AuthID)
    
num_to_str(PlayerLevel[id],vaultdata,10)
    
nvault_set(g_vault,vaultkeyvaultdata)

PHP Code:
public LoadData(id)
{
    new 
AuthID[35]
    
get_user_authid(id,AuthID,34)
    
    new 
vaultkey[64]
    
formatex(vaultkey,63,"%s-xp",AuthID)
    
PlayerXP[id] = nvault_get(g_vault,vaultkey)
    
    
formatex(vaultkey,63,"%s-level",AuthID)
    
PlayerLevel[id] = nvault_get(g_vault,vaultkey)

__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
GXLZPGX
Veteran Member
Join Date: Sep 2009
Old 11-24-2010 , 17:03   Re: Save level based on class (XP Mod)
Reply With Quote #8

Quote:
Originally Posted by Exolent[jNr] View Post
Here's an example of how I would've done the code in your first post.

PHP Code:
public SaveData(id

    new 
AuthID[35]
    
get_user_authid(id,AuthID,34)
    
    new 
vaultkey[64], vaultdata[11]
    
formatex(vaultkey,63,"%s-xp",AuthID)
    
num_to_str(PlayerXP[id],vaultdata,10)
    
nvault_set(g_vault,vaultkeyvaultdata)
    
    
formatex(vaultkey,63,"%s-level",AuthID)
    
num_to_str(PlayerLevel[id],vaultdata,10)
    
nvault_set(g_vault,vaultkeyvaultdata)

PHP Code:
public LoadData(id)
{
    new 
AuthID[35]
    
get_user_authid(id,AuthID,34)
    
    new 
vaultkey[64]
    
formatex(vaultkey,63,"%s-xp",AuthID)
    
PlayerXP[id] = nvault_get(g_vault,vaultkey)
    
    
formatex(vaultkey,63,"%s-level",AuthID)
    
PlayerLevel[id] = nvault_get(g_vault,vaultkey)

Well the way I see it, if I used your method, then no matter what class the person is, their level would stay the same. So now we're back to the reason why I created the topic.
__________________
Currently accepting payment US DOLLARS ONLY for custom plugins, contact me through PM.
GXLZPGX is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 11-24-2010 , 17:06   Re: Save level based on class (XP Mod)
Reply With Quote #9

Quote:
Originally Posted by GXLZPGX View Post
Well the way I see it, if I used your method, then no matter what class the person is, their level would stay the same. So now we're back to the reason why I created the topic.
I told you that it was an example based on the code in your first post.
All you have to do is add the class name to the level key (and the xp key if you have xp per class).
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
GXLZPGX
Veteran Member
Join Date: Sep 2009
Old 11-24-2010 , 17:11   Re: Save level based on class (XP Mod)
Reply With Quote #10

Quote:
Originally Posted by Exolent[jNr] View Post
I told you that it was an example based on the code in your first post.
All you have to do is add the class name to the level key (and the xp key if you have xp per class).
PHP Code:
formatex(vaultkey,63,"%s-level-%i-class"AuthIDpub_Class[id]) 
Unless my tiny brain is confused.

or:

PHP Code:
public Save_Data(id)  
{  
    new 
AuthID[35
    
get_user_authid(id,AuthID,34
    
    new 
vaultkey[64], vaultdata[11
    
formatex(vaultkey,63,"%s-xp",AuthID
    
num_to_str(pub_Experience[id], vaultdata10
    
nvault_set(g_vault,vaultkeyvaultdata
    
    
formatex(vaultkey,63,"%s-level"AuthID)
    
num_to_str(pub_Level[id], vaultdata10)
    
    
formatex(vaultkey,63,"%s-class"AuthID)
    
num_to_str(pub_Class[id], vaultdata10
    
nvault_set(g_Vaultvaultkeyvaultdata)

__________________
Currently accepting payment US DOLLARS ONLY for custom plugins, contact me through PM.

Last edited by GXLZPGX; 11-24-2010 at 17:16.
GXLZPGX 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 11:20.


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