Raised This Month: $ Target: $400
 0% 

Code stops getting executed at a for loop


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
justincase
Senior Member
Join Date: Dec 2008
Old 06-21-2010 , 14:53   Code stops getting executed at a for loop
Reply With Quote #1

Well, I have another weird issue, the snippet says it all:

Code:
public handleKey(id) {
    new keys[4];
    new keynames[4][16];
    
    for (new x=0; x<=4; x++) {
    
        keys[x] = random_num(0, 8);
        
        
        switch(keys[x]) {
            case 0: copy(keynames[x], 15, "MOUSE1");
            case 1: copy(keynames[x], 15, "JUMP");
            case 2: copy(keynames[x], 15, "CROUCH");
            case 3: copy(keynames[x], 15, "FORWARD");
            case 4: copy(keynames[x], 15, "BACK");
            case 5: copy(keynames[x], 15, "USE");
            case 6: { copy(keynames[x], 15, "MOVE LEFT"); keys[x] = 9; }
            case 7: { copy(keynames[x], 15, "MOVE RIGHT"); keys[x] = 10; }
            case 8: { copy(keynames[x], 15, "MOUSE2"); keys[x] = 11; }
        }

        client_print(0, print_chat, "A") // THIS GETS PRINTED OUT 4 TIMES INSTEAD OF 5 TIMES
    }
    
    client_print(0, print_chat, "FU"); // THIS DOESN'T GET PRINTED OUT

// CONCLUSION: THE WHOLE EXECUTION STOPS SUDDENDLY AFTER 4 ROUNDS
}
What's the problem? Yet another weird issue like the last time where the script suddenly stopped executing when equipping the player with a ammo_556mm_box, LOL.


EDIT: Ok, when I make it one field larger (keys[5]), it works, but why is that needed? These aren't strings, and I only need 0, 1, 2, 3, 4 (total 5).

Last edited by justincase; 06-21-2010 at 15:02.
justincase is offline
 



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 14:50.


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