Raised This Month: $ Target: $400
 0% 

Error help


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Blunr552
Member
Join Date: May 2008
Old 01-05-2011 , 17:46   Error help
Reply With Quote #1

Run Time error 4: index out of bounds
xpmod.sma:eathMsg <line 250>

PHP Code:
    while(PlayerXP[attacker] >= LEVELS[PlayerLevel[attacker]]) 
whats the problem? :/
Blunr552 is offline
shuttle_wave
Veteran Member
Join Date: Apr 2009
Location: New Zealand
Old 01-05-2011 , 17:59   Re: Error help
Reply With Quote #2

PHP Code:
if(PlayerXP[attacker] >= LEVELS[PlayerLevel[attacker]]) 
__________________
JailBreak Mod with Plugin API ( 90% ) Public
shuttle_wave is offline
Blunr552
Member
Join Date: May 2008
Old 01-05-2011 , 18:58   Re: Error help
Reply With Quote #3

Quote:
Originally Posted by shuttle_wave View Post
PHP Code:
if(PlayerXP[attacker] >= LEVELS[PlayerLevel[attacker]]) 
same error oO
Blunr552 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-05-2011 , 19:55   Re: Error help
Reply With Quote #4

What is the value of attacker and what is the value of PlayerLevel[attacker] and what is the definition of LEVELS[]?
__________________
fysiks is offline
Blunr552
Member
Join Date: May 2008
Old 01-05-2011 , 21:21   Re: Error help
Reply With Quote #5

Quote:
Originally Posted by fysiks View Post
What is the value of attacker and what is the value of PlayerLevel[attacker] and what is the definition of LEVELS[]?
I think i should have posted the whole code faster :p sorry

PHP Code:
#include <amxmodx> 
#include <amxmisc> 
#include <nvault> 

#define MAXCLASSES 5  

new PlayerXP[33],PlayerLevel[33],PlayerClass[33
//These are for your special kills 
new XP_Kill,XP_Knife,XP_Hs 
//This is for the vault, so your EXP saves to the server 
new g_vault 
//This is for the SaveXP command 
new SaveXP 

new const CLASSES[MAXCLASSES][] = { 
    
"None"
    
"Rifle Specialist"
    
"Sniper Specialist"
    
"Pistol Specialist"
    
"Machine Gun Specialist" 


new const 
LEVELS[10] = { 
    
100
    
200
    
400
    
800
    
1600
    
3200
    
6400
    
12800
    
25600
    
51200 


public 
plugin_init() 

    
register_plugin("Simple EXP Mod""1.0""Thelius"// Registers the Plugin to the ModName, Version, and Creator 
    
register_event("DeathMsg""eDeath""a"// This is the death event 
    
SaveXP register_cvar("SaveXP""1"// This is to make sure that Saving XP is enabled 
    
XP_Kill register_cvar("XP_per_kill""40"// This defines the amount of EXP you gain per kill 
    
XP_Hs register_cvar("XP_hs_bonus""50"// This defines the amount of exp gained per headshot 
    
XP_Knife register_cvar("XP_knife_bonus""20"// This defines the amount of Exp gained per Knife Kill 
    
g_vault nvault_open("XPMod"// This opens the nvault so it can save the exp 
     
    
register_clcmd("say /class""ChangeClass"// Saying /class will open the class menu 
    
register_clcmd("say_team /class""ChangeClass"// Team saying /class will open the class menu 
    
register_clcmd("say /xp""ShowHud"// Saying /xp will show your EXP 
    
register_clcmd("say_team /xp""ShowHud"// Team Saying /xp will show your EXP 


public 
eDeath( ) 

    new 
headshot,attacker read_data
    new 
weapon get_user_weapon(attacker,headshot,headshot
    
headshot read_data
     
    
PlayerXP[attacker] += get_pcvar_num(XP_Kill
     
    if(
PlayerClass[attacker] == 0
         
    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"[XP Mod] Congratulations you are now level %i %s!"PlayerLevel[attacker], CLASSES[PlayerClass[attacker]]); 
        
PlayerLevel[attacker] += 
    

    
ShowHud(attacker
    
SaveData(attacker


public 
ShowHud(id

    
set_hudmessage(025500.280.8806.012.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 ,"Rifle Specialist""1" 0); 
    
menu_additem(menu ,"Sniper Specialist""2" 0); 
    
menu_additem(menu ,"Pistol Specialist""3" 0); 
    
menu_additem(menu ,"Machine Gun Specialist""4" 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] = 
        client_print
(id,print_chat"[XP Mod] You are now a %s"CLASSES[i]) 
    } 
    else 
    { 
        
client_print(id,print_chat"[XP Mod] You are already 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] = 
    PlayerLevel
[id] = 
    PlayerClass
[id] = 


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 

Blunr552 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-05-2011 , 22:20   Re: Error help
Reply With Quote #6

You need to do some debugging. I'm thinking PlayerLevel[attacker] becomes larger than 9 (Which would cause your error).
__________________
fysiks is offline
SnoW
Veteran Member
Join Date: Oct 2008
Location: Finland WisdomNuggets: 8
Old 01-06-2011 , 06:40   Re: Error help
Reply With Quote #7

Quote:
Originally Posted by fysiks View Post
You need to do some debugging. I'm thinking PlayerLevel[attacker] becomes larger than 9 (Which would cause your error).
Code:
native min(value1, value2)
SnoW is offline
Send a message via MSN to SnoW
Blunr552
Member
Join Date: May 2008
Old 01-06-2011 , 09:41   Re: Error help
Reply With Quote #8

Quote:
Originally Posted by fysiks View Post
You need to do some debugging. I'm thinking PlayerLevel[attacker] becomes larger than 9 (Which would cause your error).
I figured the problem. It was this which caused the Error:

PHP Code:
PlayerXP[attacker
The exp was way to high, so it began to give that error, even when i saw the exp it was so bugged, that it showed some negative digits. When i resettet the exp it fixed the error.
Blunr552 is offline
SnoW
Veteran Member
Join Date: Oct 2008
Location: Finland WisdomNuggets: 8
Old 01-06-2011 , 12:56   Re: Error help
Reply With Quote #9

Quote:
Originally Posted by Blunr552 View Post
I figured the problem. It was this which caused the Error:

PHP Code:
PlayerXP[attacker
The exp was way to high, so it began to give that error, even when i saw the exp it was so bugged, that it showed some negative digits. When i resettet the exp it fixed the error.
False. You have to check that the attacker is a valid player.
SnoW is offline
Send a message via MSN to SnoW
Blunr552
Member
Join Date: May 2008
Old 01-08-2011 , 12:13   Re: Error help
Reply With Quote #10

Quote:
Originally Posted by SnoW View Post
False. You have to check that the attacker is a valid player.
how to check? oO
Blunr552 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 02:11.


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