Xeno Posted December 27, 2012 Share Posted December 27, 2012 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? Link to comment
Cadu12 Posted December 27, 2012 Share Posted December 27, 2012 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? Link to comment
Xeno Posted December 27, 2012 Author Share Posted December 27, 2012 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? Link to comment
Castillo Posted December 27, 2012 Share Posted December 27, 2012 1: https://wiki.multitheftauto.com/wiki/CountPlayersInTeam 2: You can make a table with words, and every time a chat mesage is sent ( onPlayerChat ) you check if the word is on the table. Link to comment
Xeno Posted December 27, 2012 Author Share Posted December 27, 2012 string.find That doesn't help me at all. @Castillo and Cadu12 thanks for the help, much appreciated. Link to comment
Anderl Posted December 27, 2012 Share Posted December 27, 2012 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. Link to comment
TAPL Posted December 27, 2012 Share Posted December 27, 2012 string.find That doesn't help me at all. @Castillo and Cadu12 thanks for the help, much appreciated. How it could help you if you didn't even click on it and read what it does? http://www.lua.org/manual/5.1/manual.html#pdf-string.find Link to comment
Smart. Posted December 27, 2012 Share Posted December 27, 2012 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 ";"? Link to comment
Anderl Posted December 27, 2012 Share Posted December 27, 2012 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. Link to comment
Jesseunit Posted December 27, 2012 Share Posted December 27, 2012 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. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now