Maurize Posted July 31, 2010 Share Posted July 31, 2010 Don´t know whats wrong... Maybe someone have an idea what´s wrong.. addEventHandler("onResourceStart", resourceRoot, function() for i,player in ipairs(getElementsByType("player")) do spawn(player) end end ) function spawn(player) repeat until spawnPlayer ( player, 2824.647, -2438.673+math.random(-0,5), 14, 90, 0 ) fadeCamera(source, false, 0.1, 0, 0, 0 ) end addEventHandler("onPlayerLogin", root, function() spawn(source) local playerTeam = getPlayerTeam ( player ) if ( getTeamName(playerTeam) == "Mercenaries" ) then spawnPlayer ( player, 2800.721, -2455.929, 13.630, 90, 179, team ) giveWeapon(player, 4, 68) giveWeapon(player, 22, 68) giveWeapon(player, 31, 100) giveWeapon(player, 18, 5) setPlayerStat ( thePlayer, 69, 999 ) setPlayerStat ( thePlayer, 78, 1000 ) setPlayerStat ( thePlayer, 24, 1000 ) setPlayerStat ( thePlayer, 23, 1000 ) elseif ( getTeamName(playerTeam) == "Police" ) then spawnPlayer ( player, 1580.233, -1636.650, 13.553, 90, math.random(280,281) ) giveWeapon(player, 3, 1) giveWeapon(player, 22, 68) giveWeapon(player, 29, 120) setPlayerStat ( thePlayer, 69, 750 ) setPlayerStat ( thePlayer, 76, 1000 ) setPlayerStat ( thePlayer, 24, 1000 ) setPlayerStat ( thePlayer, 23, 1000 ) else spawnPlayer ( player, 2824.647, -2438.673+math.random(-0,5), 14, 90, 0 ) giveWeapon(player, math.random(2,7)) end end ) addEventHandler("onPlayerWasted", root, function() setTimer(spawn, 5000, 1, source) end ) Link to comment
jkub Posted August 1, 2010 Share Posted August 1, 2010 Your not giving enough information. We know there is something wrong with it, but what part of it ceases to function. Is there any debug errors or warnings? Link to comment
Maurize Posted August 2, 2010 Author Share Posted August 2, 2010 it doesn´t work.. console says nothing. the point is, players will be moved if they LOGIN. that means the teams will be created if a player login. So i need something that players get their skills, skin ect. when they login. Link to comment
NotAvailable Posted August 3, 2010 Share Posted August 3, 2010 Yo maurize do something like: giveWeapon (source, 22, 40) Link to comment
Maurize Posted August 3, 2010 Author Share Posted August 3, 2010 I got this already I mean , the player will be moved in the team but he doesnt spawn on the certein position Link to comment
50p Posted August 3, 2010 Share Posted August 3, 2010 I got this already I mean , the player will be moved in the team but he doesnt spawn on the certein position Show your latest code. Make sure you don't get any warning/error messages. Link to comment
KagerA Posted August 3, 2010 Share Posted August 3, 2010 Are u sure that players don't spawn? May be you just should add setCameraTarget(player, player) into your spawn function? Link to comment
Maurize Posted August 3, 2010 Author Share Posted August 3, 2010 addEventHandler("onResourceStart", resourceRoot, function() for i,player in ipairs(getElementsByType("player")) do spawn(player) end end ) function spawn(player) local playerTeam = getPlayerTeam ( player ) if ( getTeamName(playerTeam) == "Mercenaries" ) then spawnPlayer ( player, 2800.721, -2455.929, 13.630, 90, 179 ) fadeCamera(player, true) setCameraTarget(player, player) giveWeapon(player, 4, 68) giveWeapon(player, 22, 68) giveWeapon(player, 31, 100) giveWeapon(player, 18, 5) setPlayerStat ( thePlayer, 69, 999 ) setPlayerStat ( thePlayer, 78, 1000 ) setPlayerStat ( thePlayer, 24, 1000 ) setPlayerStat ( thePlayer, 23, 1000 ) elseif ( getTeamName(playerTeam) == "Police" ) then spawnPlayer ( player, 1580.233, -1636.650, 13.553, 90, math.random(280,281) ) fadeCamera(player, true) setCameraTarget(player, player) giveWeapon(player, 3, 1) giveWeapon(player, 22, 68) giveWeapon(player, 29, 120) setPlayerStat ( thePlayer, 69, 750 ) setPlayerStat ( thePlayer, 76, 1000 ) setPlayerStat ( thePlayer, 24, 1000 ) setPlayerStat ( thePlayer, 23, 1000 ) else spawnPlayer ( player, 2824.647+math.random(-0,5), -2438.673+math.random(-0,5), 13, 90, 177 ) fadeCamera(player, true) setCameraTarget(player, player) giveWeapon(player, math.random(2,7)) end end addEventHandler("onPlayerLogin", root, function() spawn(source) end ) addEventHandler("onPlayerWasted", root, function() setTimer(spawn, 5000, 1, source) end ) and the team script: function playerJoined() check(source) end addEventHandler("onPlayerJoin",getRootElement(),playerJoined) function playerChangedNick(oldNick,newNick) setTimer(check,1000,1,source) end addEventHandler("onPlayerChangeNick",getRootElement(),playerChangedNick) function playerQuit() removePlayerFromTeam(source) end addEventHandler("onPlayerQuit",getRootElement(),playerQuit) function loggedIn() check(source) end addEventHandler("onPlayerJoin",getRootElement(),loggedIn) function loggedOut() check(source) end addEventHandler("onPlayerLogout",getRootElement(),loggedOut) function initiate() local rootNode = getResourceConfig("config.xml") local children = xmlNodeGetChildren(rootNode) if children == false then return end for _,node in pairs(children) do local attributes = xmlNodeGetAttributes(node) local name = attributes.name local color = {getColorFromString(attributes.color)} if not color[1] then color = {255,255,255} end teams[name] = attributes teams[name].color = color if not toboolean(get("noEmptyTeams")) then teams[name].team = createTeam(name,unpack(color)) end end for k,v in pairs(getElementsByType("player")) do check(v) end end addEventHandler("onResourceStart",getResourceRootElement(),initiate) function check(player) if not isElement(player) or getElementType(player) ~= "player" then debug("No player") return end local nick = getPlayerName(player) local accountName = getAccountName(getPlayerAccount(player)) for name,data in pairs(teams) do local tagMatch = false local aclGroupMatch = false if data.tag ~= nil and string.find(nick,data.tag,1,true) then tagMatch = true end if data.aclGroup ~= nil and accountName and isObjectInACLGroup("user."..accountName,aclGetGroup(data.aclGroup)) then aclGroupMatch = true end if data.required == "both" then if tagMatch and aclGroupMatch then addPlayerToTeam(player,name) return end else if tagMatch or aclGroupMatch then addPlayerToTeam(player,name) return end end end removePlayerFromTeam(player) setPlayerTeam(player,nil) end 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) debug("Added player '"..getPlayerName(player).."' to team '"..name.."'") end function removePlayerFromTeam(player) setPlayerTeam(player,nil) debug("Removed player '"..getPlayerName(player).."' from team") if toboolean(get("noEmptyTeams")) then for k,v in pairs(teams) do local team = v.team if isElement(team) and getElementType(team) == "team" then if countPlayersInTeam(team) == 0 then destroyElement(team) end end end end end function toboolean(string) if string == "false" or not string then return false end return true end setElementData(getResourceRootElement(),"debug",true) function debug(string) if getElementData(getResourceRootElement(),"debug") then outputDebugString("autoteams: "..string) end end Link to comment
NotAvailable Posted August 29, 2010 Share Posted August 29, 2010 This is like Broph.lua but then little bit more edited 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