Raised This Month: $ Target: $400
 0% 

Saving Xp and Level.


Post New Thread Closed Thread   
 
Thread Tools Display Modes
Author Message
JaGareN
Senior Member
Join Date: Mar 2009
Old 05-26-2010 , 10:46   Re: Saving Xp and Level.
#1

Quote:
Originally Posted by SaM.ThE.MaN View Post
i did what you said and it still doesnt work.
Show how you made it.

Last edited by JaGareN; 05-26-2010 at 10:51. Reason: ...
JaGareN is offline
SaM.ThE.MaN
Senior Member
Join Date: Jan 2010
Old 05-27-2010 , 04:21   Re: Saving Xp and Level.
#2

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <vault>
#include <core>
#include <fun>
#include <nvault>  

#define PLUGIN "Level Plugin"
#define VERSION "0.1"
#define AUTHOR "SaMThEMaN"

new PlayerXP[33]
new 
PlayerLevel[33]

new const 
LEVELS[6] = 
{
    
1
    
2
    
4
    
8,
    
16,
    
32
}

new 
msgtext

new gVault

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_cvar("sv_Leveler""1")
    
gVault nvault_open("Leveler")
    
register_event("DeathMsg""DeathMsg""a"
    
register_clcmd("say /level""Level")
    
register_clcmd("say_team /level""Level")
    
register_cvar("XP_per_kill""1")
}

public 
Level(id)
{
client_print(idprint_chat"^x04[Leveler] You are level %d and you have  %d XP"PlayerLevel[id], PlayerXP[id])
}

public 
SaveXP(id)
{
    new 
authid[32]; 
    
get_user_authid(id,authid,31); 

    new 
vaultkey[64], vaultdata[64]; 
    
nvault_set(gVault,vaultkey,vaultdata)
    
format(vaultkey,63,"Plvl-%s-xp",authid); 
    
format(vaultdata,63,"%d",PlayerXP[id]); 
    
set_vaultdata(vaultkey,vaultdata); 

    
format(vaultkey,63,"Plvl-%s-level",authid); 
    
format(vaultdata,63,"%d",PlayerLevel[id]); 
    
set_vaultdata(vaultkey,vaultdata);


public 
LoadXP(id)
{
    new 
authid[32]; 
    
get_user_authid(id,authid,31); 

    new 
vaultkey[64], vaultdata[64];
    
nvault_get(gVault,vaultkey,vaultdata,63
    format
(vaultkey,63,"Plvl-%s-xp",authid); 
    
get_vaultdata(vaultkey,vaultdata,63); 
    
PlayerXP[id] = str_to_num(vaultdata);   

    
format(vaultkey,63,"Plvl-%s-level",authid); 
    
get_vaultdata(vaultkey,vaultdata,63);
    
PlayerLevel[id] = str_to_num(vaultdata);  


public 
client_connect(id)
{
    if(
get_cvar_num("SaveXP") == 1) {
       
         
LoadXP(id)

         
client_print(idprint_chat"[Leveler] XP Loaded!")
         
client_print(idprint_chat"[Leveler] You are level %d and %d XP"PlayerLevel[id], PlayerXP[id])
    }
}

public 
client_disconnect(id)
{
    if(
get_cvar_num("SaveXP") == 1) {
    
         
SaveXP(id)
    }
}

public 
DeathMsg()
{
if(
get_cvar_num("sv_Leveler") == 0
{
return 
PLUGIN_HANDLED
}
    new 
attacker read_data(1)

    
PlayerXP[attacker] += get_cvar_num("XP_per_kill")

    if(
PlayerXP[attacker] >= LEVELS[PlayerLevel[attacker]]) {
    
PlayerLevel[attacker] += 1

    client_print
(attackerprint_chat"[Leveler] Congratulations! You are now level [%d]!"PlayerLevel[attacker])
    if(
get_cvar_num("SaveXP") == 1) {
 
             
SaveXP(attacker)
         }
         
ShowHUD(attacker)
    }   
    
ShowHUD(attacker)
    
    return 
PLUGIN_CONTINUE
}

public 
ShowHUD(id)    

    new 
HUD[51
    
    
//This is the stuff that will actually show in game.
    
format(HUD50"Level: %d XP: %d"PlayerLevel[id], PlayerXP[id]) 

    
message_begin(MSG_ONEmsgtext, {0,0,0}, id
    
write_byte(0
    
write_string(HUD
    
message_end() 
    return

SaM.ThE.MaN is offline
SaM.ThE.MaN
Senior Member
Join Date: Jan 2010
Old 05-29-2010 , 03:04   Re: Saving Xp and Level.
#3

is the above code wrong , can some one help me , its there in superhero mod , the xp gets saved common a lil help wont hurt
SaM.ThE.MaN is offline
Closed Thread



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 05:19.


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