Raised This Month: $ Target: $400
 0% 

Pick A Random Player Bug on Start


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Cuttlas
Senior Member
Join Date: Jan 2015
Old 12-19-2023 , 15:28   Pick A Random Player Bug on Start
Reply With Quote #1

whenever my plugin is on (amx_pugin 1), it will transfer all players to CT and then pick a random player and transfer him to T. (one vs all CT)

here is the method:

PHP Code:
public PickARandomPlayer()
{
    new 
playersT[32], playersCT[32], numTnumCT
    get_players
(playersT,numT,"e","TERRORIST")
    for(new 
i=0;i<numT;i++)
        
cs_set_user_team(playersT[i],CS_TEAM_CT)

    
get_players(playersCT,numCT,"e","CT")
        
newTerror playersCT[random_num(0,numCT-1)]
    
cs_set_user_team(newTerror ,CS_TEAM_T)

sometimes, when there are only two players on the map and both are T, if I turn on the plugin, it will give this error:

Run time error 10: native error (native "cs_set_user_team")

then I will transfer myself to CT and will re-turn on the plugin again and it will work.

where is the problem and how to avoid such issue?
__________________
To Infinity n Beyond

Last edited by Cuttlas; 12-19-2023 at 15:29.
Cuttlas 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 10:32.


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