AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved Server crashes because of this code (https://forums.alliedmods.net/showthread.php?t=293982)

xTr3m3r 02-16-2017 15:47

Server crashes because of this code
 
Hello! (Im sorry i make so many threads last days..)

So I took Exolent's HideNSeek plugin and I found a HideNSeek Deathmatch plugin somewhere and fused them. It works perfectly but there is a little glitch.

On hns deathmatch when somebody dies - some CT is taken randomly and becames a T instead. This works too. But when there is no CT on the server and a T dies - It just crashes.

Here is the code for getting a randomCT:

PHP Code:

GetRandomCT()
{
    static 
iPlayers[32], iCT_num;
    
get_players(iPlayersiCT_num"ae""CT");
        
    if(!
iCT_num)
        return 
0;
        
    return 
iCT_num iPlayers[random(iCT_num)] : iPlayers[iCT_num 1];


and this is where I use it (this is included in eventDeathMsg):

PHP Code:

new killer read_data(1);    
new 
victim read_data(2);
        if(
killer == && get_user_team(victim) == 1
        {
            new 
lucky GetRandomCT();
            
            
cs_set_user_team(lucky1);
            
client_print(luckyprint_chat"[HideNSeek] Lucky! Someone let you have their life!");
            
            
cs_set_user_team(victim2);
            
            
SetStealth(lucky);
        } 


HamletEagle 02-16-2017 15:49

Re: [Urgent] Server crashes because of this code
 
Check is_user_connected(lucky) before doing anything.

xTr3m3r 02-16-2017 15:56

Re: [Urgent] Server crashes because of this code
 
Quote:

Originally Posted by HamletEagle (Post 2495957)
Check is_user_connected(lucky) before doing anything.

I love you.


All times are GMT -4. The time now is 20:59.

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