Raised This Month: $51 Target: $400
 12% 

Solved 'strip_user_weapons' in loop error


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
redivcram
Veteran Member
Join Date: Jul 2014
Location: Serbia
Old 11-27-2017 , 15:04   'strip_user_weapons' in loop error
Reply With Quote #1

PHP Code:
    new players[32], playerCounti;
    
    
get_players(playersplayerCount"ac");
    
    for(
0playerCounti++)
    {
        if(
get_user_team(i) == && != gSimon)
        {
            
g_back2Ct[i] = true;
            
cs_set_user_team2(i1);
        }
        
        
/*>>*/strip_user_weapons(i);/*<<*/
        
give_item(i"weapon_knife");
        
        if(
!= gSimon)
            
give_item(ig_freeWeapons[random_num(0sizeof(g_freeWeapons))]);
        
        
//current_weapon(i);
    

Code:
L 11/27/2017 - 21:12:24: [FUN] Player out of range (0)
L 11/27/2017 - 21:12:24: [AMXX] Displaying debug trace (plugin "mojb_game_alien.amxx")
L 11/27/2017 - 21:12:24: [AMXX] Run time error 10: native error (native "strip_user_weapons")
L 11/27/2017 - 21:12:24: [AMXX]    [0] 081h8702.sma.p::cmdAlien (line
Solution:
PHP Code:
strip_user_weapons(i

PHP Code:
new id players[i]
strip_user_weapons(id

Last edited by redivcram; 11-28-2017 at 05:55.
redivcram is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 11-27-2017 , 15:07   Re: 'strip_user_weapons' in loop error
Reply With Quote #2

Your post is missing the generated error and some more code.
klippy is offline
redivcram
Veteran Member
Join Date: Jul 2014
Location: Serbia
Old 11-27-2017 , 15:13   Re: 'strip_user_weapons' in loop error
Reply With Quote #3

Updated.

Just noticed the player out of range error. Haven't coded in amxx since while ago.
redivcram is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 11-27-2017 , 15:16   Re: 'strip_user_weapons' in loop error
Reply With Quote #4

In your code i is not a player's ID, it's an index into the players[32] array which contains player indexes. To reference player IDs instead you should use players[i].
klippy is offline
redivcram
Veteran Member
Join Date: Jul 2014
Location: Serbia
Old 11-27-2017 , 15:19   Re: 'strip_user_weapons' in loop error
Reply With Quote #5

Quote:
Originally Posted by KliPPy View Post
In your code i is not a player's ID, it's an index into the players[32] array which contains player indexes. To reference player IDs instead you should use players[i].
Ah, thanks. Never thought of that. I always use the "i" when looping through players, big mistake. lol
redivcram 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 05:31.


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