Raised This Month: $ Target: $400
 0% 

Help with this xp mod...


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 03-04-2009 , 22:28   Re: Help with this xp mod...
Reply With Quote #3

It compiles now. I dont' know what you were doing on line 65, you will need to check that client print. Also, if you use Tabs instead of spaces for indenting code it is much much easier to read. I attached the file, take that file instead of copying from the php code box.

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <nvault>
#define PLUGIN "wizard101"
#define VERSION "1.0"
#define AUTHOR "31m0"
#define MAXCLASSES 5
new const CLASSES[MAXCLASSES][] = {
 
"Fire",
 
"Life",
 
"Ice",
 
"Eletric",
 
"Death"
}
new const 
LEVELS[] = {
 
100
 
200
 
400
 
800,
 
1600,
 
3200,
 
5000,
 
8000,
 
11000,
 
15000,
 
20000,
}
new 
PlayerXP[33],PlayerLevel[33],PlayerClass[33]
new 
XP_Kill,XP_Knife,XP_Hs,SaveXP,g_vault
public plugin_init()
{
 
register_plugin(PLUGINVERSIONAUTHOR)
 
register_event("DeathMsg""eDeath""a"
 
 
SaveXP register_cvar("SaveXP","1")
 
XP_Kill=register_cvar("XP_per_kill""20")
 
XP_Hs=register_cvar("XP_hs_bonus","20")
 
XP_Knife=register_cvar("XP_knife_bonus","20")
 
g_vault nvault_open("animod")
 
 
register_clcmd("say /class""ChangeClass")
 
register_clcmd("say_team /class""ChangeClass")
 
register_clcmd("say /xp""ShowHud")
 
register_clcmd("say_team /xp""ShowHud")
}
public 
eDeath()
{
 new 
iAttacker read_data(1)
 new 
iVictim read_data(2)
 new 
headshot read_data(3)
 new 
clipammoweapon get_user_weapon(iVictim,clip,ammo);
 
PlayerXP[iAttacker] += get_pcvar_num(XP_Kill)
 if(
headshot)
 
PlayerXP[iAttacker] += get_pcvar_num(XP_Hs)
 if(
weapon == CSW_KNIFE)
 
PlayerXP[iAttacker] += get_pcvar_num(XP_Knife)
 while(
PlayerXP[iAttacker] >= LEVELS[PlayerLevel[iAttacker]])
 {
  
client_print(iAttackerprint_chat"[Wzard Mod] Congratulations! You are a level %i %s!"LEVELS[PlayerLevel[iAttacker]], CLASSES[PlayerClass[iAttacker]])
  
PlayerLevel[iAttacker] += 1
 
}
 
 
ShowHud(iAttacker)
 
SaveData(iAttacker)
}
public 
ShowHud(id)
{
 
set_hudmessage(255000.750.0106.015.0)
 
show_hudmessage(id"Level: %i^nXP: %i^nClass: %s",PlayerLevel[id],PlayerXP[id],CLASSES[PlayerClass[id]])
}
public 
ChangeClass(id)
{
 new 
menu menu_create("Class Menu" "Class_Handle");
 
menu_additem(menu ,"Fire""1" 0);
 
menu_additem(menu ,"Life""2" 0);
 
menu_additem(menu ,"Eletric""3" 0);
 
menu_additem(menu ,"Ice""4" 0);
 
menu_additem(menu ,"Death""5" 0);
 
menu_setprop(menu MPROP_EXIT MEXIT_ALL);
 
menu_display(id menu 0);
 return 
PLUGIN_CONTINUE;
}
public 
Class_Handle(id menu item
{
 if(
item == MENU_EXIT
 {
 
menu_destroy(menu);
 }
 new 
szCommand[6] , szName[64];
 new 
access callback;
 
menu_item_getinfo(menu item access szCommand szName 63 callback);
 new 
str_to_num(szCommand)
 if(
PlayerClass[id] != i)
 {
  
PlayerClass[id] = i
  client_print
(id,print_chat,"You are now a %s",CLASSES[i])
 }
 else
 {
  
client_print(id,print_chat,"You are alredy a %s",CLASSES[i])
 }
 
menu_destroy(menu);
 return 
PLUGIN_CONTINUE
}
public 
client_connect(id)
{
 if(
get_pcvar_num(SaveXP) == 1)
 {
 
  
LoadData(id)
 }
}
public 
client_disconnect(id)
{
 if(
get_pcvar_num(SaveXP) == 1)
 {
 
  
SaveData(id)
 }
 
PlayerXP[id] = 0
 PlayerLevel
[id] = 0
 PlayerClass
[id] = 0
}
public 
SaveData(id)
{
 new 
AuthID[35]
 
get_user_authid(id,AuthID,34)
 
 new 
vaultkey[64],vaultdata[256]
 
format(vaultkey,63,"%s-Mod",AuthID)
 
format(vaultdata,255,"%i#%i#",PlayerXP[id],PlayerLevel[id])
 
nvault_set(g_vault,vaultkey,vaultdata)
 return 
PLUGIN_CONTINUE
}
public 
LoadData(id)
{
 new 
AuthID[35]
 
get_user_authid(id,AuthID,34)
 
 new 
vaultkey[64],vaultdata[256]
 
format(vaultkey,63,"%s-Mod",AuthID)
 
format(vaultdata,255,"%i#%i#",PlayerXP[id],PlayerLevel[id])
 
nvault_get(g_vault,vaultkey,vaultdata,255)
 
 
replace_all(vaultdata255"#"" ")
 
 new 
playerxp[32], playerlevel[32]
 
 
parse(vaultdataplayerxp31playerlevel31)
 
 
PlayerXP[id] = str_to_num(playerxp)
 
PlayerLevel[id] = str_to_num(playerlevel)
 
 return 
PLUGIN_CONTINUE

Attached Files
File Type: sma Get Plugin or Get Source (test.sma - 556 views - 3.7 KB)
__________________

Last edited by fysiks; 03-04-2009 at 22:32.
fysiks 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 17:00.


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