AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [Check] Jailbreak Voice (https://forums.alliedmods.net/showthread.php?t=254985)

Fuck For Fun 01-09-2015 04:05

[Check] Jailbreak Voice
 
I think that this Code, crashes my server

I want to know if this code is fine, I did test and sometimes DEAD T Team can speak.

Code:

#pragma semicolon 1

#define OVER_8000 8001

new gI_MaxClients;

new gH_LRCanSpeak;

public plugin_init()
{
    gI_MaxClients = get_maxplayers();
   
    gH_LRCanSpeak = register_cvar("amx_jailbreak_lr_can_speak", "1", 0, 1.0);
   
    register_forward(FM_Voice_SetClientListening, "OnClientSpeak");
}

Code:

public OnClientSpeak(receiver, sender, bool:listen)
{
    if(!IsValidClient(receiver) || !IsValidClient(sender))
    {
        return FMRES_IGNORED;
    }
   
    if(get_user_flags(sender) & ADMIN_LEVEL_F)
    {
        return FMRES_IGNORED;
    }
   
    if(cs_get_user_team(sender) == CS_TEAM_CT && is_user_alive(sender))
    {
        return FMRES_IGNORED;
    }
   
    if(get_pcvar_num(gH_LRCanSpeak) && is_user_alive(sender) && cs_get_user_team(sender) == CS_TEAM_T)
    {
        static count;
        count = 0;
       
        static i;
       
        for(i = 1; i <= gI_MaxClients; i++)
        {
            if(IsValidClient(i, true) && cs_get_user_team(i) == CS_TEAM_T)
            {
                count++;
            }
        }
       
        if(count == 1)
        {
            return FMRES_IGNORED;
        }
    }
   
    engfunc(EngFunc_SetClientListening, receiver, sender, false);
   
    return FMRES_SUPERCEDE;
}

stock bool:IsValidClient(client, bool:bAlive = false)
{
    if(client >= 1 && client <= gI_MaxClients && is_user_connected(client) && (bAlive == false || is_user_alive(client)))
    {
        return true;
    }
   
    return false;
}


yan1255 01-09-2015 12:27

Re: [Check] Jailbreak Voice
 
I don't know why your's crashes the server but here's something I Just built.
Its not tested and supposed to block dead prisoners voice.
PHP Code:

#include < amxmodx >
#include < fakemeta >

#define TALK_ACCESS    ADMIN_LEVEL_F

enum _:Teams
{
    
FM_TEAM_UNASSIGNED,
    
FM_TEAM_T,
    
FM_TEAM_CT,
    
FM_TEAM_SPECTATOR
};

new 
gH_LRCanSpeak;

public 
plugin_init()
{
    
register_plugin"JailBreak Voice Manager""1.0""Rejack" );
    
    
register_forwardFM_Voice_SetClientListening"FwdVoiceSetClientListening" );
    
    
gH_LRCanSpeak    register_cvar"amx_jailbreak_lr_can_speak""1" );
}    

public 
FwdVoiceSetClientListeningRecSenderbool:bListen 
{
    if ( !
is_user_connectedSender ) || !is_user_connectedRec ) )
        return 
1;
    
    if ( 
get_user_flagsSender ) & TALK_ACCESS )
        return 
1;
    
    if ( 
fm_get_user_teamSender ) == FM_TEAM_CT && is_user_aliveSender ) )
        return 
1;
    
    if ( 
get_pcvar_numgH_LRCanSpeak ) && TeamCount() == && is_user_aliveSender ) && fm_get_user_teamSender ) == FM_TEAM_T )
        return 
1;
    
    
engfuncEngFunc_SetClientListeningRecSender);
    
    return 
FMRES_SUPERCEDE;
}

stock TeamCount()
{
    static 
Players32 ], iNum;
    
    
get_playersPlayersiNum"aceh""TERRORIST" );
    
    return 
iNum;
}

stock fm_get_user_team( const index )
    return 
get_pdata_intindex114 ); 


Fuck For Fun 01-09-2015 12:39

Re: [Check] Jailbreak Voice
 
Quote:

Originally Posted by yan1255 (Post 2246972)
I don't know why your's crashes the server but here's something I Just built.
Its not tested and supposed to block dead prisoners voice.
PHP Code:

#include < amxmodx >
#include < fakemeta >

#define TALK_ACCESS    ADMIN_LEVEL_F

enum _:Teams
{
    
FM_TEAM_UNASSIGNED,
    
FM_TEAM_T,
    
FM_TEAM_CT,
    
FM_TEAM_SPECTATOR
};

new 
gH_LRCanSpeak;

public 
plugin_init()
{
    
register_plugin"JailBreak Voice Manager""1.0""Rejack" );
    
    
register_forwardFM_Voice_SetClientListening"FwdVoiceSetClientListening" );
    
    
gH_LRCanSpeak    register_cvar"amx_jailbreak_lr_can_speak""1" );
}    

public 
FwdVoiceSetClientListeningRecSenderbool:bListen 
{
    if ( !
is_user_connectedSender ) || !is_user_connectedRec ) )
        return 
1;
    
    if ( 
get_user_flagsSender ) & TALK_ACCESS )
        return 
1;
    
    if ( 
fm_get_user_teamSender ) == FM_TEAM_CT && is_user_aliveSender ) )
        return 
1;
    
    if ( 
get_pcvar_numgH_LRCanSpeak ) && TeamCount() == && is_user_aliveSender ) && fm_get_user_teamSender ) == FM_TEAM_T )
        return 
1;
    
    
engfuncEngFunc_SetClientListeningRecSender);
    
    return 
FMRES_SUPERCEDE;
}

stock TeamCount()
{
    static 
Players32 ], iNum;
    
    
get_playersPlayersiNum"aceh""TERRORIST" );
    
    return 
iNum;
}

stock fm_get_user_team( const index )
    return 
get_pdata_intindex114 ); 


I think, once you have given me this code, and i use it and it dropped (crashed) my server

So I tried to build one myself, but Dead Prisoner Talking.

Check your code and tell me if working

yan1255 01-09-2015 12:45

Re: [Check] Jailbreak Voice
 
Quote:

Originally Posted by Fuck For Fun (Post 2246980)
I think, once you have given me this code, and i use it and it dropped (crashed) my server

So I tried to build one myself, but Dead Prisoner Talking.

Check your code and tell me if working

I don't have a server to check it on.
This is a new code that I just made just now try it if you want.

Jhob94 01-09-2015 12:55

Re: [Check] Jailbreak Voice
 
if ( !is_user_connected( Sender ) || !is_user_connected( Rec ) )
return 1;

if ( get_user_flags( Sender ) & TALK_ACCESS )
return 1;

I am not sure what's the define for 1 in fakemeta, but i am sure that's wrong. If 1 = allowed to talk, you are allowing disconnected senders/receivers to speak/listen

yan1255 01-09-2015 12:58

Re: [Check] Jailbreak Voice
 
Quote:

Originally Posted by jhob94 (Post 2246997)
if ( !is_user_connected( sender ) || !is_user_connected( rec ) )
return 1;

if ( get_user_flags( sender ) & talk_access )
return 1;

i am not sure what's the define for 1 in fakemeta, but i am sure that's wrong. If 1 = allowed to talk, you are allowing disconnected senders/receivers to speak/listen

1 = frmes_ignored;

Jhob94 01-09-2015 13:01

Re: [Check] Jailbreak Voice
 
I am not in my computer so i cant check. If 1 = frmes_ignored, then you must do this:

if(!is_user_connected(sender) || !is_user_connected(receiver))
return FMRES_SUPERCEDE


All times are GMT -4. The time now is 15:29.

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