myyusuf Posted March 7, 2012 Share Posted March 7, 2012 hello scripters, i have this autoteam script. Tags = { {"LicaRe|", "LicaRe", "#00ff00", nil}, {"FuckN|", "The Fucking Noobs", "#a9d608"}, {"ES|", "Evil Spirits", "#00ff00"}, {"[weR]", "[weR] Team", "#38023C"}, {"[KCL]", "[KCL] Team", "#00ffff"}, {"[NBD]", "Never Back Down", "#0099ff"}, {"[FOTL]", "[FOTL] Team", "#aa00ff"}, {"[sMT]", "Serious Master Team", "#ff8000"}, {"[PLK]", "Polski Klan", "#ff0000"}, {"BD||", "Best Drivers", "#1e99ff"}, {"|BoB|", "Boss of Bastards", "#00cccc"}, {"Voice|", "Voice of Dick", "#c71585"}, {"=sDr=", "=sDr= Team", "#00ff00"}, {"|GM|", "Golds Mens", "#006699"}, {"|SS|", "Shadow Strikers", "#9900CC"} } function onResourceStartAutoteams() for name, data in ipairs(Tags) do --outputChatBox(" TEST: " .. name .. " " .. data[1] .. " " .. data[2] ) -- This is only for Test for id, player in ipairs(getElementsByType("player")) do if string.find(getPlayerName(player), data[1], 1, true) then --outputChatBox( "Founded: " .. getPlayerName(players) .. " as " .. data[2]) -- This is only for Test if not isElement(data[2]) or getElementType(data[2]) ~= "team" then creatingTeam = createTeam( data[2], getColorFromString ( data[3] ) ) if creatingTeam then outputDebugString( "Autoteams: Added team '" .. data[2] .. "'." ) data[4] = creatingTeam end end setTimer(function() for name, data in ipairs(Tags) do for id, player in ipairs(getElementsByType("player")) do if string.find(getPlayerName(player), data[1], 1, true) then movedteam = setPlayerTeam ( player, data[4] ) if not movedteam then MoveToTeam = getTeamFromName( data[2] ) outputDebugString( "Autoteams: Set '" .. getPlayerName(player) .. "' to team as '" .. data[2] .. "'." ) setPlayerTeam ( player, MoveToTeam ) return end outputDebugString( "Autoteams: Set '" .. getPlayerName(player) .. "' to team as '" .. data[2] .. "'." ) end end end end, 1000, 1) end end end end addEventHandler( "onResourceStart", getResourceRootElement(getThisResource()), onResourceStartAutoteams ) function onPlayerChangeNickAutoteams() setTimer(checkPlayerTeam, 100, 1, source) end addEventHandler("onPlayerChangeNick", getRootElement(), onPlayerChangeNickAutoteams) function onPlayerJoinAutoteams() setTimer(checkPlayerTeam, 100, 1, source) end addEventHandler( "onPlayerJoin", getRootElement(), onPlayerJoinAutoteams ) function addPlayerToTeam(player,name) local team = teams[name].team if not isElement(team) or getElementType(team) ~= "team" then team = createTeam(teams[name].name,unpack(teams[name].color)) teams[name].team = team end setPlayerTeam(player,team) blip = createBlipAttachedTo ( player ) local r, g, b = getTeamColor(team) setBlipColor ( blip, r, g, b, 255 ) debug("Added player '"..getPlayerName(player).."' to team '"..name.."'") end function onPlayerQuitAutoteams() -- Remove teams if players are not team returnPlayerTeam = getPlayerTeam( source ) if returnPlayerTeam then setPlayerTeam( source, nil ) if countPlayersInTeam(returnPlayerTeam) == 0 then destroyElement(returnPlayerTeam) end end end addEventHandler( "onPlayerQuit", getRootElement(), onPlayerQuitAutoteams ) function checkPlayerTeam(player) local publicplayer = player for name, data in ipairs(Tags) do if string.find(getPlayerName(player), data[1], 1, true) then if not isElement(data[4]) or getElementType(data[4]) ~= "team" then creatingTeam = createTeam( data[2], getColorFromString ( data[3] ) ) if creatingTeam then outputDebugString( "Autoteams: Added team '" .. data[2] .. "'." ) data[4] = creatingTeam end end setTimer(function() for name, data in ipairs(Tags) do if string.find(getPlayerName(publicplayer), data[1], 1, true) then movedteam = setPlayerTeam ( publicplayer, data[4] ) if not movedteam then MoveToTeam = getTeamFromName( data[2] ) outputDebugString( "Autoteams: Set '" .. getPlayerName(publicplayer) .. "' to team as '" .. data[2] .. "'." ) setPlayerTeam ( publicplayer, MoveToTeam ) return end outputDebugString( "Autoteams: Set '" .. getPlayerName(publicplayer) .. "' to team as '" .. data[2] .. "'." ) end end end, 2000, 1) else -- Remove teams if players are not team returnPlayerTeam = getPlayerTeam( player ) if returnPlayerTeam then setPlayerTeam( player, nil ) if countPlayersInTeam(returnPlayerTeam) == 0 then destroyElement(returnPlayerTeam) end end end end end i try to make setVehicleColor with team name. it isnt working. can you help me? color = getTeamColor ( playerTeam ) local r, g, b = getTeamColor(team) setVehicleColor ( color, r, g, b, 255 ) Link to comment
Kenix Posted March 7, 2012 Share Posted March 7, 2012 https://wiki.multitheftauto.com/wiki/Scr ... troduction Link to comment
myyusuf Posted March 7, 2012 Author Share Posted March 7, 2012 https://wiki.multitheftauto.com/wiki/Scripting_Introduction wiki helps me. i fixed by myself. thanks 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