Raised This Month: $ Target: $400
 0% 

Solved Server crashes because of this code


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
xTr3m3r
Member
Join Date: Feb 2010
Old 02-16-2017 , 15:47   Server crashes because of this code
Reply With Quote #1

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);
        } 

Last edited by xTr3m3r; 02-16-2017 at 15:57.
xTr3m3r is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 02-16-2017 , 15:49   Re: [Urgent] Server crashes because of this code
Reply With Quote #2

Check is_user_connected(lucky) before doing anything.
__________________
HamletEagle is offline
xTr3m3r
Member
Join Date: Feb 2010
Old 02-16-2017 , 15:56   Re: [Urgent] Server crashes because of this code
Reply With Quote #3

Quote:
Originally Posted by HamletEagle View Post
Check is_user_connected(lucky) before doing anything.
I love you.
xTr3m3r is offline
Reply


Thread Tools
Display Modes

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 20:59.


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