Jump to content

Get amount of players on team and blacklisted words.


Xeno

Recommended Posts

Posted

I swear I've asked this before, but I've forgot. How do I get the amount of players on a team?

And is it possible to blacklist certain words, and how?

Posted
function getCashFromTeamPlayers(team) 
    local amount = 0 
    if isElement(team) and getElementType(team) == "team" then 
        for i, v in ipairs(getPlayersInTeam(team)) do 
            amount = amount + (getPlayerMoney(v) or 0) 
        end 
    end 
    return amount 
end 

2nd, what do you mean by that?

Posted

I mean get the amount of players inside the team, not the cash all added up.

2. For example if someone swore and you wanted to censor it, how would you know he was swearing?

Posted
local g_pCensoredWords = 
{ 
    "bitch", 
    "gay"; 
}; 
  
addEventHandler( "onPlayerChat", root, 
    function( szMsg ) 
        for index, word in ipairs( g_pCensoredWords ) do 
            if ( szMsg:find( word, 0 ) ) then 
                szMsg = szMsg:gsub( word, "****" ); 
                szMsg = string.format( "%s: %s", getPlayerName( source ), szMsg ); 
  
                cancelEvent(); 
                outputChatBox( szMsg, root, 255, 255, 255, true ); 
            end 
        end 
    end 
) 

Not tested but should work.

Posted
local g_pCensoredWords = 
{ 
    "bitch", 
    "gay"; 
}; 
  
addEventHandler( "onPlayerChat", root, 
    function( szMsg ) 
        for index, word in ipairs( g_pCensoredWords ) do 
            if ( szMsg:find( word, 0 ) ) then 
                szMsg = szMsg:gsub( word, "****" ); 
                szMsg = string.format( "%s: %s", getPlayerName( source ), szMsg ); 
  
                cancelEvent(); 
                outputChatBox( szMsg, root, 255, 255, 255, true ); 
            end 
        end 
    end 
) 

Not tested but should work.

Why do you use idiotic variable names and whatsup with the ";"?

Posted
Why do you use idiotic variable names and whatsup with the ";"?

It's not "idiotic", it's called hungarian notation: http://en.wikipedia.org/wiki/Hungarian_notation - Almost all programmers use it.

I use ";" because I want so, any problems? I can script whatever way I want.

+1 Anderl, although you shouldn't waste any time on Sebbe for future reference since he fails at scripting anyway.

Let's see how long it'll take for Símon to delete this post.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...