AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   XP when killing won't work... (https://forums.alliedmods.net/showthread.php?t=62947)

BigDontCry 11-08-2007 03:50

XP when killing won't work...
 
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
 



[ --<-@ ] Black Rose 11-08-2007 11:26

Re: XP when killing won't work...
 
new xplevel_lev[MAX_LEVEL] = 0
new xpgiven_lev[MAX_LEVEL] = 0
->
new xplevel_lev[MAX_LEVEL] = { 0, 230, 568, ... }
new xpgiven_lev[MAX_LEVEL] = { 2, 5, 10, 25 ... }



xpgiven = xpgiven_lev[p_level[Killer]] <-This becomes 0

BigDontCry 11-08-2007 11:38

Re: XP when killing won't work...
 
No, I happend to put this line within the else statement:

xpgiven_lev[j] = XP_BASE + (j * XP_ADD_LEVEL)

[ --<-@ ] Black Rose 11-08-2007 12:01

Re: XP when killing won't work...
 
kk


All times are GMT -4. The time now is 01:20.

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