Raised This Month: $ Target: $400
 0% 

XP when killing won't work...


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
BigDontCry
Member
Join Date: Nov 2007
Location: Sweden
Old 11-08-2007 , 03:50   XP when killing won't work...
Reply With Quote #1

Hi.

I have a problem with my plugin. When I kill a enemy I should get some XP, but I don't... When I kill someone I go from level 0 to level 10 instantly without recieving any XP at all...

PHP Code:
#define MAX_LEVEL 11
#define XP_BASE 60
#define XP_ADD_LEVEL 20
 
new p_xp[33], p_level[33
new 
p_rank[33] = ""
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 
PHP Code:
public client_putinserver(id) {
 if(
is_user_connected(id) {
  
p_level[id] = 0
  p_xp
[id] = 0
  
  set_xp
()
  
set_ranktitle(id)
  
displaylevel(id)
 }

PHP Code:
public hook_death() {
 
 new 
Killer read_data(1)
 new 
Victim read_data(2)
 new 
headshot read_data(3)
 
 new 
KillerName[32], VictimName[32]
 if(
is_user_connected(Killer) && is_user_connected(Victim)) {
  
get_user_name(KillerKillerName31)
  
get_user_name(VictimVictimName31)
   
  if(!
headshot) {
   
xpgiven xpgiven_lev[p_level[Killer]]
   
p_xp[Killer] += xpgiven
   client_print
(Killerprint_chat"[%s] You recieved %d XP for killing %s"MODxpgivenVictimName)
  } else {
   
xpgiven xpgiven_lev[p_level[Killer]] + 50
   p_xp
[Killer] += xpgiven
   client_print
(Killerprint_chat"[%s] You recieved %d XP for killing %s with a headshot"MODxpgivenVictimName)
  }
  
  
displaylevel(Killer)
 }
  
 return 
PLUGIN_CONTINUE

I think my problem is somewhere in this code... set_xp()

PHP Code:
public set_xp() {
 
 for(new 
0MAX_LEVEL; ++j) {
  if(
<= 10) {
   
xplevel_lev[j] = xplevel_base[j]
  } else {
 
   
xpgiven_lev[j] = XP_BASE + (XP_ADD_LEVEL)
 
   if(
get_cvar_float("mp_xpmultiplier")) {
    new 
Float:xpmultiplier get_cvar_float("mp_xpmultiplier")
    
xplevel_lev[j] = floatround(xplevel_lev[j] * xpmultiplier)
   }
  }
 }

PHP Code:
public displaylevel(id) {
 
 if(!
id || !is_user_connected(id))
  return 
PLUGIN_CONTINUE
 
 
new xpstring[511] = ""
 
new bool:lvled false
 
new name[32]
 
 
get_user_name(idname31)
 
 if (
p_xp[id] < 0) {
  
p_xp[id] = 0
 
}
 
 if((
p_level[id] < (MAX_LEVEL-1)) && (p_xp[id] >= xplevel_lev[p_level[id]+1])) {
  for (new 
= (p_level[id]+1); MAX_LEVELi++) {
   if (
p_xp[id] >= xplevel_lev[i]) {
    
lvled true
    p_level
[id] = i
   
}
  }
 }
 
 
set_ranktitle(id)
 
 
format(xpstring1023"Rank: [%s] Level: [%d] XP: [%d]"p_rank[id], p_level[id], p_xp[id])
 
 
message_begin(MSG_ONEgmsgStatusText, {0,0,0}, id)
 
write_byte(0)
 
write_string(xpstring)
 
message_end()
 
 if(
lvled) {
 
  
set_hudmessage(255255127, -1.00.716.03.0)
  
show_hudmessage(id"Congratulations! You gained a level!")
 
  
client_print(0print_chat"[%s] Announcement: %s gained a level"MODname)
 
  
emit_sound(id,CHAN_AUTO"plats/elevbell1.wav"1.0ATTN_NORM0PITCH_LOW)
 
 }
 
 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-08-2007 at 04:10.
BigDontCry is offline
 


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:20.


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