AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Frustration!!! (2 Problems) (https://forums.alliedmods.net/showthread.php?t=12723)

BioHazardousWaste 04-22-2005 18:27

Frustration!!! (2 Problems)
 
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.

BioHazardousWaste 04-22-2005 20:44

OK, I dunno wtf is going on. I think i've almost got it to work (for me). I've modded my code so much over the past few hours, it could have been anything. So i'm starting to get happy, although not really happy because i'm still a level 100 with 0 experience. :twisted: So anyways, i'm getting happy, then some random asshole comes and joins my server and it says game commencing; then BOOM! it crashes!!! How the hell can I fix the problem if it crashes and I can't see the error? Anybody, somebody? Please help me :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry:

BioHazardousWaste 04-22-2005 22:41

Wow... it is now 10:40 PM and I finally figured out that the error was equivelant to an integer overflow. It's only been about 7 hours since I first got it! Congratualtions, excuse me while I go slit my wrist, and thanx for the help.


All times are GMT -4. The time now is 09:53.

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