Raised This Month: $ Target: $400
 0% 

Need Help with Save XP and Load XP


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
desert
Junior Member
Join Date: Jan 2006
Location: Canada
Old 07-20-2007 , 21:09   Need Help with Save XP and Load XP
Reply With Quote #1

Hey, i've been trying to use nvault to create a load and save xp method for my mod but i can't seem to figure it out. mySQL is out of the question because i don't have a database to link it to and vault is just to laggy so i was thinking either nvault or vaultx. if anyones willing to help me set up those methods please pm me or post on this thread.


Code:
#include <amxmodx> #include <amxmisc> #include <cstrike> #include <engine> #include <fun> #include <nvault> new const PLUGIN[] = "AvP" new const VERSION[] = "1.0" new const AUTHOR[] = "Desert" #define CS_ARMOR_NONE 0 #define CS_ARMOR_KEVLAR 1 #define CS_ARMOR_VESTHELM 2 #define VAULTNAME "playerXPinfo" new enable_cvar, avp_hp,avp_ap new neededxp[33] new statusMsg new vault new bandage[33] new g_maxplayers public plugin_init() {  register_plugin(PLUGIN, VERSION, AUTHOR)  enable_cvar =    register_cvar("sv_avp", "1")  avp_hp    = register_cvar("sv_avphp", "500")  avp_ap    = register_cvar("sv_avpap", "500")    register_event("HLTV" , "new_round_start" , "a" , "1=0" , "2=0")    register_clcmd("say /bandage", "buyBandage")  //this stores the message id for sending StatusText messages  statusMsg = get_user_msgid("StatusText")  g_maxplayers = get_maxplayers()    vault = nvault_open(VAULTNAME) } public plugin_end(){  nvault_close(vault) } public plugin_precache(){  precache_model("models/player/predator_t/predator_t.mdl")  precache_model("models/player/predator_ct/predator_ct.mdl")  precache_model("models/player/gign/gign.mdl")  precache_model("models/player/terror/terror.mdl")   } public predator() {  if (get_pcvar_num(enable_cvar) == 1) {   for (new id = 1; id <= g_maxplayers; id++) {    new team = get_user_team(id)        new client_name[33]    get_user_name(id, client_name, 32)        if(is_user_alive(id)) {         if (team == 1) {      cs_set_user_model(id, "predator_t")     }         if (team == 2) {      cs_set_user_model(id, "predator_ct")     }         client_print(id, print_chat, "[AvP] Client: %s Has become a Predator.", client_name)         set_user_health(id, get_pcvar_num(avp_hp))         new CsArmorType:ArmorType     cs_set_user_armor(id, get_pcvar_num(avp_ap),ArmorType)        }         }  }  else {   for (new ids = 1; ids <= g_maxplayers; ids++) {    new team = get_user_team(ids)        if(is_user_alive(ids)) {         if (team == 1) {      cs_set_user_model(ids, "terror")     }         if (team == 2) {      cs_set_user_model(ids, "gign")     }    }   }  } } public new_round_start() {    if (get_pcvar_num(enable_cvar) == 1) {   set_task(1.0 , "predator")   set_task(1.0 , "avp_stats",_,_,_, "b")   set_task(1.0 , "health_loss",_,_,_, "b")   set_task(1.0, "SaveXP",_,_,_,"b")     for( new id = 1; id <= g_maxplayers; id++) {    bandage[id] = 0   }  } } public avp_stats () {  if (get_pcvar_num(enable_cvar) == 1) {   for (new id = 1; id <= g_maxplayers; id++){    if(is_user_alive(id) && !is_user_bot(id)) {     new client_name[33]     get_user_name(id, client_name, 32)         new health = get_user_health(id)         new CsArmorType:ArmorType     new armor = cs_get_user_armor(id, ArmorType)         new levelxp[33], level[33]         neededxp[id]  = (get_user_frags(id) * 20) - (get_user_deaths(id)*10);         if (neededxp[id] < 100) {      levelxp[id] = 100      level[id] = 1     }         if(neededxp[id] >= 100){      levelxp[id] = 200      level[id] = 2      set_user_gravity (id, 0.5)            if (neededxp[id] >= 200) {       levelxp[id] = 400       level[id] = 3       set_user_footsteps(id, 1)             if (neededxp[id] >= 400) {        levelxp[id] = 800        level[id] = 4        set_user_rendering(id,kRenderFxGlowShell,0,0,0,kRenderTransAlpha,20)                if (neededxp[id] >= 800) {         levelxp[id] = 1600         level[id] = 5         set_task(5.0, "health_regen",_,_,_,"b")                 if (neededxp[id] >= 1600) {          neededxp[id] = 1600         }        }       }      }     }         //need to make a place where we can save the message     new message[64];         //this basicly works like the second half of the client_print function (also other functions)     //only instead of sending the message, or doing something with it, it just stores it into your first argument     formatex(message, 64, "[AvP] Health:%d Armor:%d Level:%d XP:%d/%d",health, armor, level[id], neededxp[id], levelxp[id])     message_begin( MSG_ONE, statusMsg, {0,0,0}, id)     write_byte(0)     write_string(message)     message_end()        }   }  } } public buyBandage (id){  bandage[id] = 1 } public health_loss() {  for ( new id = 1; id <= g_maxplayers; id++) {   new health = get_user_health(id)   if(health <= 100) {    if(bandage[id] == 1) {     set_user_health(id, health)    }    else {     set_user_health(id, health - 1)    }   }  } } public health_regen() {  for ( new id = 1; id <= g_maxplayers; id++) {   neededxp[id]  = (get_user_frags(id) * 20) - (get_user_deaths(id)*10);   if (neededxp[id] >= 800) {    if(get_user_health(id) < get_pcvar_num(avp_hp)) {     set_user_health(id,get_user_health(id) + 1)    }    else {     break;    }    if(neededxp[id] >= 1600) {     if(get_user_health(id) < get_pcvar_num(avp_hp) + 500) {      set_user_health(id,get_user_health(id) + 1)     }     else {      break;     }    }   }  } } public SaveXP () {    if (vault == INVALID_HANDLE) {   client_print(0, print_console, "xp was not saved / loaded")  }    for ( new id = 1; id <= g_maxplayers; id++) {   new AuthID[33]   new XP[33]     get_user_authid(id, AuthID, 32)     format(XP,sizeof(XP),"%i",neededxp[id])     nvault_set(vault, AuthID, XP)  } } public client_authorized(id) {  new AuthID[33]  new XP[33]    format(XP,sizeof(XP),"%i",neededxp[id])  get_user_authid(id, AuthID, 32)  nvault_get(vault, AuthID,XP) }





---------------------------------------------------------------------------------------------
Predator Mod v1.0 - [==========] (80%) done. need save / load xp system

Last edited by desert; 07-21-2007 at 00:02.
desert is offline
 



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 21:26.


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