AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [Help] Very simple (https://forums.alliedmods.net/showthread.php?t=279884)

The Professional 03-03-2016 15:02

[Help] Very simple
 
I just want to get active For T team

I do not know how to use this command;
PHP Code:

if(cs_get_user_team(id) == CS_TEAM_T


PHP Code:

#include <amxmodx>
#include <cstrike>
#include <fakemeta>

#define PLUGIN "New Plugin"
#define VERSION "1.0"
#define AUTHOR "Alka"

#define STEP_DELAY 4.5

new Float:g_fNextStep[33];

#define MAX_SOUNDS 4 //Max num of sound for list below

new const g_szStepSound[MAX_SOUNDS][] = {
    
    
"zombie_plague/zombie_madness1.wav",
    
"zombie_plague/zombie_burn5.wav",
    
"zombie_plague/zombie_madness1.wav",
    
"zombie_plague/zombie_burn5.wav"
};

public 
plugin_init() {
    
    
register_plugin(PLUGINVERSIONAUTHOR);
    
    
register_forward(FM_PlayerPreThink"fwd_PlayerPreThink"0);
}

public 
plugin_precache()
{
    new 
i;
    for(
0MAX_SOUNDS i++)
        
precache_sound(g_szStepSound[i]);
}

public 
fwd_PlayerPreThink(id)
{
    if(!
is_user_alive(id))
        return 
FMRES_IGNORED;
    
    
set_pev(idpev_flTimeStepSound999);
    
    if(
g_fNextStep[id] < get_gametime())
    {
        if(
fm_get_ent_speed(id) && (pev(idpev_flags) & FL_ONGROUND))
            
emit_sound(idCHAN_BODYg_szStepSound[random(MAX_SOUNDS)], VOL_NORMATTN_STATIC0PITCH_NORM);
        
        
g_fNextStep[id] = get_gametime() + STEP_DELAY;
    }
    return 
FMRES_IGNORED;
}

stock Float:fm_get_ent_speed(id)
{
    if(!
pev_valid(id))
        return 
0.0;
    
    static 
Float:vVelocity[3];
    
pev(idpev_velocityvVelocity);
    
    
vVelocity[2] = 0.0;
    
    return 
vector_length(vVelocity);



Artifact 03-03-2016 15:11

Re: [Help] Very simple
 
In public fwd_PlayerPreThink(id) command add
PHP Code:

if(get_user_team(id) == 2)
    return 
FMRES_IGNORED

get_user_team(id)
Code:

1 = Terrorist
2 = Counter-Terrorist


The Professional 03-03-2016 15:20

Re: [Help] Very simple
 
Thanks, worked.

addons_zz 03-03-2016 16:12

Re: [Help] Very simple
 
I would advise to try avoid use magic numbers. https://github.com/notepad-plus-plus/notepad-plus-plus/blob/master/CONTRIBUTING.md#avoid-magic-numbers

Use the https://www.amxmodx.org/api/cstrike#counter-strike-team-id-constants.

As CS_TEAM_CT is from an enum, use _: to untag.
Code:
if(get_user_team(id) == _:CS_TEAM_CT)     return FMRES_IGNORED;

HamletEagle 03-04-2016 13:16

Re: [Help] Very simple
 
Quote:

Originally Posted by addons_zz (Post 2399023)
I would advise to try avoid use magic numbers. https://github.com/notepad-plus-plus/notepad-plus-plus/blob/master/CONTRIBUTING.md#avoid-magic-numbers

Use the https://www.amxmodx.org/api/cstrike#counter-strike-team-id-constants.

As CS_TEAM_CT is from an enum, use _: to untag.
Code:
if(get_user_team(id) == _:CS_TEAM_CT)     return FMRES_IGNORED;

Lol, there is no magic number. Everyone should know that 1 is T team and 2 CT team. In this case, it's okay to write them directly.

Bugsy 03-04-2016 19:10

Re: [Help] Very simple
 
If the enum is available I'd rather see 'CS_TEAM_T' than '1'. Not saying I'd add the cstrike include just for that, but if it's there use it. I try to eliminate numbers that stand for things whenever I can, and do usually make enums.

siriusmd99 03-05-2016 03:53

Re: [Help] Very simple
 
Look for fm_get_user_team if you don't want to include the cstrike module. It's actually the same, you will have to define function,team offsets and enum, I've seen it while scripting into biohazard source code, you can copy it from that plugin.

The Professional 03-05-2016 06:09

Re: [Help] Very simple
 
Tamam sakin olun şampiyonlar benim için kavga etmeyin :))

addons_zz 03-05-2016 17:33

Re: [Help] Very simple
 
OK champions calm, do not fight for me


All times are GMT -4. The time now is 03:25.

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