MrEpicness Posted February 15, 2016 Posted February 15, 2016 Hello, Earlier today I've started scripting a gate system (XML). The result seems ok, everything works just the way I wanted to make it work. Now sadly I ran into 1 problem, I can't get the gate locked to multiple teams or classess. I figured out it'd probably require the split() function, but I have no idea how to properly implent it. Server side addEventHandler("onResourceStart", getResourceRootElement(), function() local xml = xmlLoadFile("gates.xml") -- open the XML file local messageNodes = xmlNodeGetChildren(xml) -- get all child nodes of the root node () gates = {} -- create a new global variable to store the welcome messages for i,node in ipairs(messageNodes) do -- loop over all the message nodes local gateID = xmlNodeGetAttribute(node, "object") local posX = xmlNodeGetAttribute(node, "posX") local posY = xmlNodeGetAttribute(node, "posY") local posZ = xmlNodeGetAttribute(node, "posZ") local rotX = xmlNodeGetAttribute(node, "rotX") local rotY = xmlNodeGetAttribute(node, "rotY") local rotZ = xmlNodeGetAttribute(node, "rotZ") local permType = xmlNodeGetAttribute(node, "permType") local permTo = xmlNodeGetAttribute(node, "permTo") local gates = createObject(gateID, posX, posY, posZ) setElementRotation(gates, rotX, rotY, rotZ) local fX = xmlNodeGetAttribute(node, "fX") local fY = xmlNodeGetAttribute(node, "fY") local fZ = xmlNodeGetAttribute(node, "fZ") local fHeight = xmlNodeGetAttribute(node, "fHeight") local fRadius = xmlNodeGetAttribute(node, "fRadius") local tempCol = createColTube ( fX, fY, fZ, fRadius, fHeight ) local newX = xmlNodeGetAttribute(node, "newX") local newY = xmlNodeGetAttribute(node, "newY") local newZ = xmlNodeGetAttribute(node, "newZ") function openGate(thePlayer) if permType == "team" then if getTeamName(getPlayerTeam(thePlayer)) == permTo then playSoundFrontEnd(thePlayer, 5) moveObject(gates, 3000, newX, newY, newZ) end elseif permType == "class" then if getElementData(thePlayer, "class") == permTo then playSoundFrontEnd(thePlayer, 5) moveObject(gates, 3000, newX, newY, newZ) end end end function closeGate(thePlayer) local orgX, orgY, orgZ = getElementData(gates, "orgpos") moveObject(gates, 3000, posX, posY, posZ) end addEventHandler ( "onColShapeHit", tempCol, openGate) addEventHandler ( "onColShapeLeave", tempCol, closeGate) end xmlUnloadFile(xml) end ) If some of you could enlighten me, that'd be great! I'm also open for feedback! Thanks in advance.
tosfera Posted February 16, 2016 Posted February 16, 2016 You would have to split the text indeed, you could add teamnames in a string like; team1,team2,team3. Use the split function to get the teams and see if one of the teams is assigned to the player.
MrEpicness Posted February 16, 2016 Author Posted February 16, 2016 "but I have no idea how to properly implent it" ^^
MrEpicness Posted February 16, 2016 Author Posted February 16, 2016 top kek. I just fixed it myself, ay lmao. Thanks anyway!
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