Raised This Month: $ Target: $400
 0% 

Variable (array?) trouble...


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
BigDontCry
Member
Join Date: Nov 2007
Location: Sweden
Old 11-16-2007 , 06:18   Variable (array?) trouble...
Reply With Quote #1

Hey.

What I'm trying to do is this:
PHP Code:
#define MAX_PLAYERS 33
#define TOTAL_RACES 5
 
new g_PlayerXP[MAX_PLAYERS][TOTAL_RACES]
new 
g_PlayerLevel[MAX_PLAYERS][TOTAL_RACES
...and when I try this for example:
PHP Code:
g_PlayerXP[id][3] = 200
client_print
(idprint_chat"XP: %d"g_PlayerXP[id][3]) 
It just returns 0 when I try to print it on screen...

Suggestions?
__________________
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
BigDontCry is offline
Old 11-16-2007, 08:48
BigDontCry
This message has been deleted by BigDontCry.
Old 11-16-2007, 10:28
Careface
This message has been deleted by Careface.
BigDontCry
Member
Join Date: Nov 2007
Location: Sweden
Old 11-16-2007 , 12:04   Re: Variable (array?) trouble...
Reply With Quote #4

PHP Code:
public show_player_stats(id) {
 
 new 
bool:lvled false
 
new g_Pl_Race g_PlayerRace[id]
 
 if(
g_PlayerXP[id][g_Pl_Race] < 0) {
  
g_PlayerXP[id][g_Pl_Race] = 0
 
}
 
 if((
g_PlayerLevel[id][g_Pl_Race] < (MAX_LEVEL-1)) && (g_PlayerXP[id][g_Pl_Race] >= xplevel_lev[g_PlayerLevel[id][g_Pl_Race]+1])) {
  for(new 
= (g_PlayerLevel[id][g_Pl_Race]+1); MAX_LEVEL; ++i) {
   if(
g_PlayerXP[id][g_Pl_Race] >= xplevel_lev[i]) {
    
lvled true
    g_PlayerLevel
[id][g_Pl_Race] += i
   
}
  }
 }
 
 
set_player_race(id)
 
 
set_hudmessage(025500.020.701.05.0)
 
show_hudmessage(id"Race: %s^nLevel: %d^nXP: %d"g_PlayerRaceName[id], g_PlayerLevel[id][g_Pl_Race], g_PlayerXP[id][g_Pl_Race])
 
 if(
lvled) {
 
  
set_hudmessage(25500, -1.0, -1.010.56.0)
  
show_hudmessage(id"Congratulations! You gained a level!!!^nYou are now level %d"g_PlayerLevel[id][g_Pl_Race])
 
  if (
file_exists("sound/wishmaster/levelup2.wav")==&& is_user_alive(id)) {
   
emit_sound(id,CHAN_AUTO"wishmaster/levelup2.wav"1.0ATTN_NORM0PITCH_NORM)
  }
 }
 
 return 
PLUGIN_CONTINUE

The clients level is always "0"... It never changes...
__________________
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-16-2007 at 14:03.
BigDontCry is offline
BigDontCry
Member
Join Date: Nov 2007
Location: Sweden
Old 11-16-2007 , 14:04   Re: Variable (array?) trouble...
Reply With Quote #5

Here's my "death" function...

PHP Code:
public death() {
 
 new 
killer read_data(1)
 new 
victim read_data(2)
 new 
headshot read_data(3)
 
 new 
g_Pl_Race g_PlayerRace[killer]
 
 new 
kname[32], vname[32]
 
get_user_name(killerkname31)
 
get_user_name(victimvname31)
 
 if(
is_user_connected(killer)) {
 
  
xpgiven xpgiven_lev[g_PlayerLevel[killer][g_Pl_Race]]
  
g_PlayerXP[killer][g_Pl_Race] += xpgiven
 
  client_print
(killerprint_chat"[%s] You recieved %d XP for killing %s"MODxpgivenvname)
 
 }
 
 return 
PLUGIN_CONTINUE

The players XP won't increase...
The client_print shows the right information (lvl 0 get 60 XP for a kill)... But it just won't add that to the clients XP....
__________________
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
BigDontCry is offline
[ --<-@ ] Black Rose
ANNIHILATED
Join Date: Sep 2005
Location: Stockholm, Sweden.
Old 11-16-2007 , 15:15   Re: Variable (array?) trouble...
Reply With Quote #6

show xplevel_lev
[ --<-@ ] Black Rose is offline
BigDontCry
Member
Join Date: Nov 2007
Location: Sweden
Old 11-16-2007 , 15:33   Re: Variable (array?) trouble...
Reply With Quote #7

PHP Code:
new g_PlayerXP[MAX_PLAYERS][TOTAL_RACES]
new 
g_PlayerLevel[MAX_PLAYERS][TOTAL_RACES]
new 
g_PlayerRace[MAX_PLAYERS]
new 
g_PlayerRaceName[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 
PHP Code:
public set_xp_frontend() {
 
 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)
 }


Plugin_init
PHP Code:
public plugin_init() {
 
 
register_plugin("MyMod""1.0""Greven")
 
 
register_event("DeathMsg""death""a")
 
set_task(0.01"set_xp_frontend"456)
 
set_task(0.1"show_player_stats",0,"",0,"b")

__________________
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-16-2007 at 15:36.
BigDontCry is offline
BigDontCry
Member
Join Date: Nov 2007
Location: Sweden
Old 11-16-2007 , 15:41   Re: Variable (array?) trouble...
Reply With Quote #8

Oh, darn... I see the problem... set_task in plugin_init, it doesn't forward the id to show_player_stats(id) function....

I want the stats to be on-screen all the time, is there a smoother way than client_PreThink to do this? My experience is that client_PreThink lags the server quite alot...
__________________
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-16-2007 at 15:44.
BigDontCry 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 01:12.


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