Raised This Month: $ Target: $400
 0% 

HUD message not showing right


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
BigDontCry
Member
Join Date: Nov 2007
Location: Sweden
Old 11-15-2007 , 02:54   HUD message not showing right
Reply With Quote #1

Hi.

I have major problem with a plugin I'm working on. I can't figure out what's wrong with it. But every time when I should gain XP; I don't... I don't level up and so on...

The HUD Status text says:
Rank: Dead Knight
Level: 0
XP : 0

ALL the time... No matter if I recieve XP...

Here's my code:
mymod.sma:
PHP Code:
public plugin_init() {
 
 
register_plugin("My Mod""1.0""KoVeNaNT")
 
 
register_event("DeathMsg""death""a")
 
 
register_logevent("event_player_action"3"1=triggered")
 
 
set_task(0.01"set_xp"456)
 
set_task(0.1"showStats",0,"",0,"b")
 

mymod_defines.inc:
PHP Code:
// *** RACES *******************************************
#define RACE_NONE  0
#define RACE_NECROMANCER 1
#define RACE_PRIEST  2
#define RACE_AVALON  3
#define RACE_DEADKNIGHT  4
#define RACE_WISHMASTER  5
// *****************************************************
#define NUM_OF_RACES 6
 
#define XP_PER_LEVEL  600
#define XP_PER_LEVEL_BASE 2500
#define XP_BASE   60
#define XP_ADD_LEVEL  20 
mymod_variables.inc:
PHP Code:
new player_xp[MAX_PLAYERS][NUM_OF_RACES]
new 
player_level[MAX_PLAYERS][NUM_OF_RACES]
new 
player_race[MAX_PLAYERS]
new 
p_race[MAX_PLAYERS][18]
new 
xplevel_base[11] = {0,150,300,600,1000,1500,2100,2800,3600,4500,5500}
new 
xplevel_lev[MAX_LEVEL] = 0
new xpgiven_lev[MAX_LEVEL] = 0
new xpgiven 
mymod_infoevent.inc: This is where my problem is, I think...
PHP Code:
public showStats(id) {
 
 new 
bool:Lvled false
 
 
if(player_xp[id][player_race[id]] < 0) {
  
player_xp[id][player_race[id]] = 0
 
}
 
 if((
player_level[id][player_race[id]] < (MAX_LEVEL-1)) && (player_xp[id][player_race[id]] >= xplevel_lev[player_level[id][player_race[id]+1]])) {
  for(new 
= (player_level[id][player_race[id]+1]); MAX_LEVEL; ++i) {
   if(
player_xp[id][player_race[id]] >= xplevel_lev[i]) {
    
Lvled true
    player_level
[id][player_race[id]] = i
   
}
  }
 }
 
 
setRace(id)
 
 
set_hudmessage(025500.020.701.05.0)
 
show_hudmessage(id"Race: %s^nLevel: %d^nXP: %d"p_race[id], player_level[id][player_race[id]], player_xp[id][player_race[id]])
 
 if(
Lvled) {
 
  
set_hudmessage(25500, -1.0, -1.010.56.0)
  
show_hudmessage(id"Congratulations! You gained a level!!!^nYou are now level %d"player_level[id][player_race[id]])
 
  if (
file_exists("sound/mymod/levelup2.wav")==&& is_user_alive(id)) {
   
emit_sound(id,CHAN_AUTO"mymod/levelup2.wav"1.0ATTN_NORM0PITCH_NORM)
  }
 
 }
 
 return 
PLUGIN_CONTINUE

mymod_events.inc: or maybe here?
PHP Code:
public death() {
 
 new 
killer read_data(1)
 new 
victim read_data(2)
 
 new 
kname[32], vname[32]
 
get_user_name(killerkname31)
 
get_user_name(victimvname31)
 
 if(
is_user_connected(killer)) {
  
xpgiven xpgiven_lev[player_level[killer][player_race[killer]]]
  
player_xp[killer][player_race[killer]] += xpgiven
 
  client_print
(killerprint_chat"[%s] You recieved %d XP for killing %s"MODxpgivenvname)
 }
 
 return 
PLUGIN_CONTINUE
}
public 
event_player_action() {
 
 new 
sArg[MAX_VAR_LENGTH], sAction[MAX_VAR_LENGTH]
 new 
sName[MAX_NAME_LENGTH]
 new 
idiUserId
 
 read_logargv
(0sArgMAX_VAR_LENGTH)
 
read_logargv(2sActionMAX_VAR_LENGTH)
 
parse_loguser(sArgsNameMAX_NAME_LENGTHiUserId)
 
id find_player("k"iUserId)
 
 if(
id == 0) {
  return 
PLUGIN_CONTINUE
 
}
 
 new 
temp 0
 
 
if(equal(sAction"Planted_The_Bomb")) {
  
temp xpgiven_lev[player_level[id][player_race[id]]]
  
player_xp[id][player_race[id]] += temp
 
  client_print
(idprint_chat"[%s] You recieved %d XP for planting the bomb"MODtemp)
 } else if(
equal(sAction"Defused_The_Bomb")) {
  
temp xpgiven_lev[player_level[id][player_race[id]]]
  
player_xp[id][player_race[id]] += temp
 
  client_print
(idprint_chat"[%s] You recieved %d XP for defusing the bomb"MODtemp)
 } else if(
equal(sAction"Dropped_The_Bomb")) {
  
temp xpgiven_lev[player_level[id][player_race[id]]]
  
player_xp[id][player_race[id]] -= temp
 
  client_print
(idprint_chat"[%s] You lost %d XP for dropping the bomb"MODtemp)
 } else if(
equal(sAction"Got_The_Bomb")) {
  
temp xpgiven_lev[player_level[id][player_race[id]]] / 2
  player_xp
[id][player_race[id]] += temp
 
  client_print
(idprint_chat"[%s] You recieved %d XP for picking up the bomb"MODtemp)
 } else if(
equal(sAction"Touched_A_Hostage")) {
  
temp xpgiven_lev[player_level[id][player_race[id]]] / 2
  player_xp
[id][player_race[id]] += temp
 
  client_print
(idprint_chat"[%s] You recieved %d XP for beginning escorting the hostage"MODtemp)
 } else if(
equal(sAction"Rescued_A_Hostage")) {
  
temp = (xpgiven_lev[player_level[id][player_race[id]]])
  
player_xp[id][player_race[id]] += temp
 
  client_print
(idprint_chat"[%s] You recieved %d XP for escorting a hostage to safety"MODtemp)
 } else if(
equal(sAction"Killed_A_Hostage")) {
  
temp xpgiven_lev[player_level[id][player_race[id]]] * 2
  player_xp
[id][player_race[id]] -= temp
 
  client_print
(idprint_chat"[%s] You lost %d XP for killing a hostage!"MODtemp)
 } else if(
equal(sAction"Spawned_With_The_Bomb")) {
  
temp xpgiven_lev[player_level[id][player_race[id]]] / 2
  player_xp
[id][player_race[id]] += temp
 
  client_print
(idprint_chat"[%s] You recieved %d XP for spawning with the bomb"MODtemp)
 }
 return 
PLUGIN_HANDLED
 

With this code a HUD message will pop up in the middle of the screen saying; "Congratulations! You just gained a level......." ALL the time even if I didn't gained a level (so Lvled = true when it shouldn't)

...and my status won't change either when I gain XP, it's always:
Rank: Dead Knight
Level: 0
XP: 0

Anyone have a solution for me?

OH, I forgot the set_xp():
PHP Code:
public set_xp() {
 
 for(new 
0MAX_LEVELj++) {
  if(
<= 10) {
   
xplevel_lev[j] = xplevel_base[j]
  } else {
   
xplevel_lev[j] = XP_PER_LEVEL_BASE + ((10) * XP_PER_LEVEL)
  }
  
  
xpgiven_lev[j] = XP_BASE + (XP_ADD_LEVEL)
  
 }
 
 return 
PLUGIN_CONTINUE
 

__________________
Big Men Don't Cry

Quote:
[20:23] [email protected]: I don't know how
[20:23] [email protected]: I'm only 15
[20:23] [email protected]: I don't know anything

Last edited by BigDontCry; 11-15-2007 at 02:57.
BigDontCry is offline
Reply


Thread Tools
Display Modes

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


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