laserlaser Posted November 18, 2010 Share Posted November 18, 2010 (edited) Hello mates,again me The my new script!! but i write old days This is server-side : function refreshTeams() local xml = xmlLoadFile("teams.xml") local teamCount=0 local name local tag local r local g local b local tm while xmlFindChild(xml,"team",teamCount) do local child = xmlFindChild(xml,"team",teamCount) name = xmlNodeGetAttribute(child,"name") tag = xmlNodeGetAttribute(child,"tag") r = xmlNodeGetAttribute(child,"r") g = xmlNodeGetAttribute(child,"g") b = xmlNodeGetAttribute(child,"b") if not getTeamFromName(name) then table.insert(teams,name) table.insert(teamsTag,tag) tm=createTeam(tostring(name),tonumber(r),tonumber(g),tonumber(b)) for k,v in ipairs( getElementsByType("player") ) do if string.find(getPlayerName(v),tag) then setPlayerTeam(v,tm) end end end teamCount=teamCount+1 end end function addTeam(name,tag,r,g,b) local xml = xmlLoadFile("teams.xml") local newTeam = xmlCreateChild(xml,"team") xmlNodeSetAttribute(newTeam,"name",name) xmlNodeSetAttribute(newTeam,"tag",tag) xmlNodeSetAttribute(newTeam,"r",tostring(r)) xmlNodeSetAttribute(newTeam,"g",tostring(g)) xmlNodeSetAttribute(newTeam,"b",tostring(b)) xmlSaveFile(xml) table.insert(teams,name) table.insert(teamsTag,tag) local tm = createTeam(tostring(name),tonumber(r),tonumber(g),tonumber(b)) if tm then outputChatBox(name .. " Adlı Takım Eklendi,TAG:"..tag.."...") end for k,v in ipairs (getElementsByType("player")) do if string.find(getPlayerName(v),tag) then setPlayerTeam(v,tm) end end end function onResourceStart(res) refreshTeams() for _,z in ipairs(getElementsByType("player")) do, for k,v in ipairs(teamsTag) do if string.find(getPlayerName(z),tostring(v)) then setPlayerTeam(z,getTeamFromName(teams[k])) break end end end local team for k,v in ipairs( teams ) do team = getTeamFromName(v) if isElement(team) then if countPlayersInTeam( team ) == 0 then destroyElement(team) end end end end addEventHandler("onResourceStart",getResourceRootElement(getThisResource()),onResourceStart) -- function onPlayerJoin() refreshTeams() for k,v in ipairs(teamsTag) do if string.find(getPlayerName(source),tostring(v)) then setPlayerTeam(source,getTeamFromName(teams[k])) break end end local team for k,v in ipairs( teams ) do team = getTeamFromName(v) if isElement(team) then if countPlayersInTeam( team ) == 0 then destroyElement(team) end end end end addEventHandler("onPlayerJoin",getRootElement(),onPlayerJoin) -- function onPlayerChangeNick(old,new) local count=0 refreshTeams() for k,v in ipairs(teamsTag) do if string.find(new,tostring(v)) then setPlayerTeam(source,getTeamFromName(teams[k])) count=1 break end end if count==0 then setPlayerTeam(source,nil) end local team for k,v in ipairs( teams ) do team = getTeamFromName(v) if isElement(team) then if countPlayersInTeam( team ) == 0 then destroyElement(team) end end end end addEventHandler("onPlayerChangeNick",getRootElement(),onPlayerChangeNick) function cmdAddTeam(player,cmd,tag,r,g,b,...) local e = { ... } local name = "none" if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)),aclGetGroup("Admin")) then for k,v in ipairs(e) do if name=="none" then name=v else name=name.." "..v end end addTeam(name,tag,r,g,b) end end addCommandHandler("addteam",cmdAddTeam) /addteam özelliğini sadece adminler kullanabilir. /addteam tag r g b name örnek kullanım : /addteam |OS| 255 0 0 Old Soldiers <teams> <team name="Old Soldiers" tag="|OS|" r="255" g="0" b="0" /> <!-- <team name="Team Name" tag="Team Tag" r="Color R" g="Color G" b="Color B" --> </teams> Made in TURKEY -War OF Empire- Edited April 25, 2011 by Guest Link to comment
Aibo Posted November 18, 2010 Share Posted November 18, 2010 you know, there are already teams in MTA Link to comment
laserlaser Posted November 18, 2010 Author Share Posted November 18, 2010 you know, there are already teams in MTA yes But for clans Link to comment
Klesh Posted December 4, 2010 Share Posted December 4, 2010 This resource is ready? and if it is, when player left and join again, the player still in the team? 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