[DARKRP] Combine Footstep, how add more team?


function GM:PlayerFootstep( ply, pos, foot, sound, volume, rf ) 
    local Team = ply:Team()
    if Team == TEAM_OTA1 then
     ply:EmitSound("npc/combine_soldier/gear"..math.random(1, 6)..".wav") 
     else
       
     return false
 end
end


I have this code for one team, i can’t add more team…


function GM:PlayerFootstep( ply, pos, foot, sound, volume, rf ) 
    local Team = ply:Team()
    if Team == TEAM_OTA1 or TEAM_ANOTHER then
     ply:EmitSound("npc/combine_soldier/gear"..math.random(1, 6)..".wav") 
     else
       
     return false
 end
end


Found it ! :smiley:

Replace else with elseif ( TEAM == TEAM_***** ) then

Then you can add another team. Although, if you’re adding a lot of teams it’d be quicker to set up a table of sounds…


local TEAM_FOOTSTEP_SOUNDS = {
	[ TEAM_OTA1 ] = {
		"npc/combine_soldier/gear1.wav";
		"npc/combine_soldier/gear2.wav";
		"npc/combine_soldier/gear3.wav";
		"npc/combine_soldier/gear4.wav";
		"npc/combine_soldier/gear5.wav";
		"npc/combine_soldier/gear6.wav";
	};

	[ TEAM_ ] = {

	};
};

function GM:PlayerFootstep( _p, _pos, _foot, _sound, _volume, _rf )
	// Don't continue if player is invalid
	if ( !IsValid( _p ) ) then return false; end

	// Try to grab sounds from the table
	local _sounds = TEAM_FOOTSTEP_SOUNDS[ _p:Team( ) ];

	// If the data at [ TEAM_* ] is a table, choose random sound, otherwise if a string is used, use it, otherwise false..
	return ( ( _sounds && istable( _sounds ) ) && table.Random( _sounds ) || ( ( _sounds ) && _sounds || false ) );
end

“npc/combine_soldier/gear1.wav”;

shouldn’t there be a “,” ?

Both commas and semi-colons work in tables. I personally prefer semi-colons ( for multi-line tables; single-line tables get commas ) because it fits with the rest of my code.

thank you ! You’re awesome

EDIT:

Shit ! It don’t work, the footstep is for all teams