Raised This Month: $ Target: $400
 0% 

Help with this xp mod...


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
31m0_owns
Member
Join Date: May 2008
Location: SLH, New Jersey-- U.S.A
Old 03-04-2009 , 21:28   Help with this xp mod...
Reply With Quote #1

I am trying to make a mod... but i am new to coding idk why i tried but when i compile i get 19 errors here is the code if oyu can help

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <nvault>
#define PLUGIN "wizard101"
#define VERSION "1.0"
#define AUTHOR "31m0"
#define MAXCLASSES 5
public plugin_init() {
 
register_plugin(PLUGINVERSIONAUTHOR)
 
new const 
CLASSES[MAXCLASSES][] = {
    
"Fire",
    
"Life",
    
"Ice",
    
"Eletric",
    
"Death"
}
new const 
LEVELS[10] = {
    
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("Wizard 101""1.0""Fxfighter")
 
    
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 
iVictim read_data)
    new 
headshot read_data)
    new 
clipammoweapon get_user_weapon(id,clip,ammo);
 
    
PlayerXP[attacker] += get_pcvar_num(XP_Kill)
 
    if(
headshot)
    
PlayerXP[attacker] += get_pcvar_num(XP_Hs)
 
    if(
weapon == CSW_KNIFE)
    
PlayerXP[attacker] += get_pcvar_num(XP_Knife)
 
 
    while(
PlayerXP[attacker] >= LEVELS[PlayerLevel[attacker]])
    {
      
client_print(attackerprint_chat"[Wzard Mod] Congratulations! You are a level %i %s!",
      
PlayerLevel[attacker] += 1
    
}
    
ShowHud(attacker)
    
SaveData(attacker)
}
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 
__________________
Project(s):
Prop-Hunt: 5%
Killcam: NEVER GOING TO HAPPEN!!!
31m0_owns is offline
31m0_owns
Member
Join Date: May 2008
Location: SLH, New Jersey-- U.S.A
Old 03-04-2009 , 21:36   Re: Help with this xp mod...
Reply With Quote #2

/home/groups/amxmodx/tmp3/phpxZbTaa.sma(15) : warning 217: loose indentation
/home/groups/amxmodx/tmp3/phpxZbTaa.sma(34) : error 018: initialization data exceeds declared size
/home/groups/amxmodx/tmp3/phpxZbTaa.sma(37) : error 029: invalid expression, assumed zero
/home/groups/amxmodx/tmp3/phpxZbTaa.sma(54) : error 029: invalid expression, assumed zero
/home/groups/amxmodx/tmp3/phpxZbTaa.sma(54) : error 017: undefined symbol "eDeath"
/home/groups/amxmodx/tmp3/phpxZbTaa.sma(5 : error 017: undefined symbol "id"
/home/groups/amxmodx/tmp3/phpxZbTaa.sma(60) : error 017: undefined symbol "attacker"
/home/groups/amxmodx/tmp3/phpxZbTaa.sma(63) : error 017: undefined symbol "attacker"
/home/groups/amxmodx/tmp3/phpxZbTaa.sma(66) : error 017: undefined symbol "attacker"
/home/groups/amxmodx/tmp3/phpxZbTaa.sma(69) : error 017: undefined symbol "attacker"
/home/groups/amxmodx/tmp3/phpxZbTaa.sma(71) : error 017: undefined symbol "attacker"
/home/groups/amxmodx/tmp3/phpxZbTaa.sma(71) : warning 215: expression has no effect
/home/groups/amxmodx/tmp3/phpxZbTaa.sma(71) : warning 215: expression has no effect
/home/groups/amxmodx/tmp3/phpxZbTaa.sma(71 -- 72) : error 017: undefined symbol "attacker"
/home/groups/amxmodx/tmp3/phpxZbTaa.sma(74) : error 017: undefined symbol "ShowHud"
/home/groups/amxmodx/tmp3/phpxZbTaa.sma(75) : error 017: undefined symbol "SaveData"
/home/groups/amxmodx/tmp3/phpxZbTaa.sma(77) : error 029: invalid expression, assumed zero
/home/groups/amxmodx/tmp3/phpxZbTaa.sma(77) : error 017: undefined symbol "ShowHud"
/home/groups/amxmodx/tmp3/phpxZbTaa.sma(80) : error 017: undefined symbol "id"
/home/groups/amxmodx/tmp3/phpxZbTaa.sma(80) : warning 215: expression has no effect
/home/groups/amxmodx/tmp3/phpxZbTaa.sma(80) : error 017: undefined symbol "id"
/home/groups/amxmodx/tmp3/phpxZbTaa.sma(80) : error 029: invalid expression, assumed zero
/home/groups/amxmodx/tmp3/phpxZbTaa.sma(80) : fatal error 107: too many error messages on one line

these are the errors i get
__________________
Project(s):
Prop-Hunt: 5%
Killcam: NEVER GOING TO HAPPEN!!!
31m0_owns is offline
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 - 557 views - 3.7 KB)
__________________

Last edited by fysiks; 03-04-2009 at 22:32.
fysiks is offline
31m0_owns
Member
Join Date: May 2008
Location: SLH, New Jersey-- U.S.A
Old 03-05-2009 , 07:11   Re: Help with this xp mod...
Reply With Quote #4

thnx but when i go to compile it it won't show a lnik for it but there are no errors
__________________
Project(s):
Prop-Hunt: 5%
Killcam: NEVER GOING TO HAPPEN!!!
31m0_owns is offline
31m0_owns
Member
Join Date: May 2008
Location: SLH, New Jersey-- U.S.A
Old 03-05-2009 , 07:36   Re: Help with this xp mod...
Reply With Quote #5

well i was wondering...
PHP Code:
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"
I was wondering if these had to go before the rest of the code for it to compile or is this just fine...
__________________
Project(s):
Prop-Hunt: 5%
Killcam: NEVER GOING TO HAPPEN!!!
31m0_owns is offline
iNspiratioN
Member
Join Date: Feb 2009
Location: Lithuania
Old 03-05-2009 , 09:37   Re: Help with this xp mod...
Reply With Quote #6

Quote:
Originally Posted by 31m0_owns View Post
well i was wondering...
PHP Code:
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"
I was wondering if these had to go before the rest of the code for it to compile or is this just fine...
I think there's no diffrence
iNspiratioN is offline
31m0_owns
Member
Join Date: May 2008
Location: SLH, New Jersey-- U.S.A
Old 03-05-2009 , 09:38   Re: Help with this xp mod...
Reply With Quote #7

k thnx
__________________
Project(s):
Prop-Hunt: 5%
Killcam: NEVER GOING TO HAPPEN!!!
31m0_owns is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 03-05-2009 , 19:39   Re: Help with this xp mod...
Reply With Quote #8

Quote:
Originally Posted by 31m0_owns View Post
thnx but when i go to compile it it won't show a lnik for it but there are no errors
Interesting, it works fine for me. Maybe your browser is trying to handle the download differently.


Quote:
Originally Posted by 31m0_owns View Post
well i was wondering...

I was wondering if these had to go before the rest of the code for it to compile or is this just fine...
plugin_init() will be executed first (or nearly first) regardless of where it is located in the file.
__________________
fysiks is offline
BOYSplayCS
BANNED
Join Date: Apr 2008
Location: Gainesville, FL
Old 03-05-2009 , 19:41   Re: Help with this xp mod...
Reply With Quote #9

I don't know what is with you and tabs, but that does NOT make the code easier to read. Don't tell me otherwise, I work with this stuff. Also, indenting looks way neater and professional - it also improves skills. Tabs are unappealing and shouldn't normally be used when coding.
BOYSplayCS 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 17:00.


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