AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Voice Block - 3 warnings (https://forums.alliedmods.net/showthread.php?t=208524)

maneljinho 02-14-2013 14:57

Voice Block - 3 warnings
 
close!

wickedd 02-14-2013 15:19

Re: Voice Block - 3 warnings
 
You can ignore it. If you really want to fix it, search "loose indentation".

maneljinho 02-14-2013 15:23

Re: Voice Block - 3 warnings
 
close!

naven 02-14-2013 15:54

Re: Voice Block - 3 warnings
 
Code:

CheckLastTerrorist()
{
    new players[32], pnum;
    get_players(players, pnum, "ae", "TERRORIST");
 
    g_last_terrorist = (pnum == 1) ? players[0] : 0;

  if(g_last_terrorist) {
  client_printcolor(0,"^4[CSNACIONAL] ^3O ultimo terrorista pode falar ao microfone." )
}
if(g_last_terrorist) {
  new players[32], num, player;
            get_players( players, num, "a" );
           
            for( new i = 0; i < num; i++ )
            {
                player = players[i];
               
                switch( cs_get_user_team( player ) )
                {
                    case CS_TEAM_CT:
                    {
                set_user_godmode( player, 0 );
                    }
                   
                    case CS_TEAM_T:
                    {
 
}

}
}
}

}

It should look like that:
Code:

CheckLastTerrorist()
{
        new players[32], pnum;
        get_players(players, pnum, "ae", "TERRORIST");
 
        g_last_terrorist = (pnum == 1) ? players[0] : 0;
       
        if(g_last_terrorist)
        {
                client_printcolor(0,"^4[CSNACIONAL] ^3O ultimo terrorista pode falar ao microfone." )
        }
        if(g_last_terrorist)
        {
                new players[32], num, player;
                get_players( players, num, "a" );
               
                for( new i = 0; i < num; i++ )
                {
                        player = players[i];
               
                        switch( cs_get_user_team( player ) )
                        {
                                case CS_TEAM_CT:
                                {
                                        set_user_godmode( player, 0 );
                                }
                   
                                case CS_TEAM_T:
                                {
                                        //code
                                }

                        }
                }
        }
}

Much better, ain't it?

leonardo_ 02-14-2013 15:55

Re: Voice Block - 3 warnings
 
Quote:

Originally Posted by maneljinho (Post 1894393)
can tell me how to do it please?

You can ignore as wickedd said, or you need to change spaces in the code.

for example:
PHP Code:

CheckLastTerrorist()
{
    new 
players[32], pnum;
    
get_players(playerspnum"ae""TERRORIST");
   
    
g_last_terrorist = (pnum == 1) ? players[0] : 0;

  if(
g_last_terrorist) {
   
client_printcolor(0,"^4[CSNACIONAL] ^3O ultimo terrorista pode falar ao microfone." )


change into this:

PHP Code:

CheckLastTerrorist()
{
    new 
players[32], pnum;
    
get_players(playerspnum"ae""TERRORIST");
   
    
g_last_terrorist = (pnum == 1) ? players[0] : 0;

if(
g_last_terrorist) {
   
client_printcolor(0,"^4[CSNACIONAL] ^3O ultimo terrorista pode falar ao microfone." )


I only changed space in the front of if, that's it.

that line:
PHP Code:

if(g_last_terrorist) { 

This code should work: (try)
PHP Code:

#include <amxmodx> 
#include <amxmisc> 
#include <hamsandwich>
#include <fakemeta> 
#include <fun>
#include <cstrike>

#define ADMIN_VOICE ADMIN_IMMUNITY

#define OFFSET_TEAM 114 
#define fm_cs_get_user_team(%1) get_pdata_int(%1, OFFSET_TEAM) 

#define CS_TEAM_T 1 
#define CS_TEAM_CT 2 

new bool:g_connected[33]; 

new 
g_max_clients
new 
g_last_terrorist;


public 
plugin_init() 

    
register_plugin("No Terrorist Voice""0.1""Exolent"); 
    
    
RegisterHam(Ham_Spawn"player""FwdPlayerSpawnPost"1);
    
RegisterHam(Ham_Killed"player""FwdPlayerKilledPost"1);
    
    
register_forward(FM_Voice_SetClientListening"FwdSetVoice"); 
    
    
g_max_clients get_maxplayers(); 


public 
client_putinserver(client

    
g_connected[client] = true


public 
client_disconnect(client

    
g_connected[client] = false


public 
FwdPlayerSpawnPost(id)
{
    if( 
is_user_alive(id) )
    {
        
CheckLastTerrorist();
    }
}

public 
FwdPlayerKilledPost()
{
    
CheckLastTerrorist();
}

CheckLastTerrorist()
{
    new 
players[32], pnum;
    
get_players(playerspnum"ae""TERRORIST");
    
g_last_terrorist = (pnum == 1) ? players[0] : 0;
    
    if(
g_last_terrorist
    {
    
client_printcolor(0,"^4[CSNACIONAL] ^3O ultimo terrorista pode falar ao microfone." )
    }
    
    if(
g_last_terrorist) {
    new 
players[32], numplayer;
    
get_playersplayersnum"a" );
    
    
    for( new 
0numi++ )
    {
    
player players[i];
    
    switch( 
cs_get_user_teamplayer ) )
    {
    case 
CS_TEAM_CT:
    {
    
set_user_godmodeplayer);
    }
    case 
CS_TEAM_T:
    {
    
    }

}
}
}

}

public 
FwdSetVoice(receiversenderbool:listen

    if( !(
<= receiver <= g_max_clients
    || !
g_connected[receiver
    || !(
<= sender <= g_max_clients
    || !
g_connected[sender] ) return FMRES_IGNORED
    
    new 
team fm_cs_get_user_team(sender); 
    if( (
team == CS_TEAM_T && sender != g_last_terrorist || team == CS_TEAM_CT && !is_user_alive(sender)) && !access(senderADMIN_VOICE) ) 
    { 
        
engfunc(EngFunc_SetClientListeningreceiversender0); 
        return 
FMRES_SUPERCEDE
    } 
    
    return 
FMRES_IGNORED
}  


stock client_printcolor(target, const message[], any:...)
{
    static 
buffer[512], iargscount
    argscount 
numargs()
    
    static 
g_msgSayText_cpg_MaxPlayers_cp;
    if(!
g_msgSayText_cp) {
        
g_msgSayText_cp get_user_msgid("SayText");
    }
    if(!
g_MaxPlayers_cp) {
        
g_MaxPlayers_cp get_maxplayers();
    }

    
    
// Send to everyone
    
if (!target)
    {
        static 
player
        
for (player 1player <= g_MaxPlayers_cpplayer++)
        {
            
// Not connected
            
if (!is_user_connected(player))
                continue;
            
            
// Remember changed arguments
            
static changed[5], changedcount // [5] = max LANG_PLAYER occurencies
            
changedcount 0
            
            
// Replace LANG_PLAYER with player id
            
for (2argscounti++)
            {
                if (
getarg(i) == LANG_PLAYER)
                {
                    
setarg(i0player)
                    
changed[changedcount] = i
                    changedcount
++
                }
            }
            
            
// Format message for player
            
vformat(buffercharsmax(buffer), message3)
            
            
replace_all(buffercharsmax(buffer), "!g""^4");
            
replace_all(buffercharsmax(buffer), "!y""^1");
            
replace_all(buffercharsmax(buffer), "!t""^3");
            
            
// Send it
            
message_begin(MSG_ONE_UNRELIABLEg_msgSayText_cp_player)
            
write_byte(player)
            
write_string(buffer)
            
message_end()
            
            
// Replace back player id's with LANG_PLAYER
            
for (0changedcounti++)
                
setarg(changed[i], 0LANG_PLAYER)
        }
    }
    
// Send to specific target
    
else
    {
        
// Format message for player
        
vformat(buffercharsmax(buffer), message3)
        
        
replace_all(buffercharsmax(buffer), "!g""^4");
        
replace_all(buffercharsmax(buffer), "!y""^1");
        
replace_all(buffercharsmax(buffer), "!t""^3");
        
        
// Send it
        
message_begin(MSG_ONEg_msgSayText_cp_target)
        
write_byte(target)
        
write_string(buffer)
        
message_end()
    }


Hope that this information will be helpful for you.

maneljinho 02-14-2013 15:58

Re: Voice Block - 3 warnings
 
close!


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

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