Hey guys
I'm getting really frustrated and feel like giving up, but I've done so much work I don't want to. I've been getting the weirdest errors since I added this line : num_to_str(PlayerExp[id],tmp_PlayerExp,32) Although it's probably unrelated. Anyways, here's the latest: Fuck... server crashed, hold on.
Problem #1
Quote:
|
L 04/22/2005 - 18:15:23: [AMXX] Run time error 4 (index out of bounds) on line 112 (file "ma_matrix.sma").
|
Code:
register_event("ResetHUD", "NewRound", "be")//Call PlayerSpawn whenever someone spawns - in plugin _init
new PlayerAlliance[34] = 0 //in vars.inc
public NewRound()
{
for(i=0;i<32;i++)
{
if(ReadyToLoad[i] == 1)
{
ReadyToLoad[i] = 0
LoadPlayer(i)
new Name[32], Alliance[32]
if (PlayerAlliance[i] == 0) //line 112 (error here)
copy(Alliance, 32, "Blue Pills")
else if (PlayerAlliance[i] == 1)
copy(Alliance, 32, "Zionists")
else if (PlayerAlliance[i] == 2)
copy(Alliance, 32, "Machines")
else if (PlayerAlliance[i] == 3)
copy(Alliance, 32, "Exiles")
get_user_name(i, Name, 31)
//show other users
set_hudmessage(255, 255, 255, 0.5, 0.5, 0, 6.0, 12.0, 0.1, 0.2, 4)
show_hudmessage(0, "Beware: %s has joined the fight for the %s", Name, Alliance)
}
CheckLevel(i)
}
}
Any idea what the problem is? I can't see how it can be invalid, because it goes from 0 to 32 and the array is from 0 to 34.
Problem #2
When the users exp is loaded, it is supposed to run through a quick calculation to tell the users level and say "You are level #x" However, it always says 100; even if someone has 0 exp.
Code:
new ExperienceForLevel[101] //levels, 0 - 100 (in vars.inc)
//the following is in plugin _init
//bullshit to put levels, because using {} to assign values gives the error line to long
ExperienceForLevel[0] = 0
bullshit = 5
for(new i=1;i<101 ;i++)
{
bullshit = floatround(bullshit * 1.337)
ExperienceForLevel[i] = bullshit
}
//end relevant plugin_init code
//load exp procedure
public LoadExp(id)
{
//get user AuthID
new AuthID[34], value[9]
new key[99]
get_user_authid(id, AuthID, 33)
format(key, 98, "%s_exp", AuthID)
get_vaultdata(key, value, 8)
PlayerExp[id] = str_to_num(value)
PlayerFocus[id] = PlayerLevel[id]
//recreate bullshit to figure out level
bullshit = 5
for(i=1;i<101;i++)
{
bullshit = floatround(bullshit * 1.337)
if(PlayerExp[id] > bullshit || PlayerExp[id] == bullshit)
{
PlayerLevel[id] = i
}
}
set_hudmessage(255, 255, 255, 0.5, 1.0, 1, 6.0, 25.0, 0.1, 0.2, 4)
show_hudmessage(0, "You are currently level #%i", PlayerLevel[id])
//Debug
client_print (0, print_console, "User %s is level %i", AuthID, PlayerLevel[id])
client_print (0, print_console, "Exp data (%s) loaded for user: %s", value, AuthID)
client_print (0, print_console, "Current exp = %i", PlayerExp[id])
}
Right now those are my 2 biggest problems, I still don't think you gain exp right, but i'll get to that after these. If someone can give me a hand, i'd really appreciate it.
__________________
"What then is truth? Truths are illusions which we have forgotten are illusions - they are metaphors that have become worn out... this (truth) is the duty to lie according to a fixed convention.
-Friedrich Nietzsche