AnnaBelle Posted April 17, 2017 Share Posted April 17, 2017 addCommandHandler("tent",function(thePlayer) if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(thePlayer)),aclGetGroup("Admin"))then local x,y,z = getElementPosition(thePlayer) local xr,yr,zr = getElementRotation(thePlayer) px,py,pz = getElementPosition(thePlayer) prot = getPedRotation(thePlayer) local offsetRot = math.rad(prot+90) local vx = px+1.5*math.cos(offsetRot) local vy = py+1.5*math.sin(offsetRot) local vz = pz+2 local vrot = prot+180 tent = createObject(964,vx,vy,z-1,0,0,vrot) setObjectScale(tent,1.0) tentCol = createColSphere(x,y,z,4) attachElements(tentCol,tent,0,0,0) setElementData(tentCol,"parent",tent) setElementData(tent,"parent",tentCol) setElementData(tentCol,"tent",true) setElementData(tentCol,"vehicle",true) ------------------------------------------------// setElementData(tentCol,"M4A1 CCO",5000) ------------------------------------------------// outputChatBox("[TENT]#FFFFFFTent Spawned!",source,46,255,46,true) else outputChatBox("[TENT]#FFFFFFYou are not admin!",source,255,0,0,true) end end) Can anyone help me with the admin only script remove this tent And players can not remove Link to comment
AE. Posted April 17, 2017 Share Posted April 17, 2017 (edited) use destroyElement and set data to false Edited April 17, 2017 by 3laa33 Link to comment
AnnaBelle Posted April 17, 2017 Author Share Posted April 17, 2017 as? I want only a member of the administration to remove the tent. Link to comment
AE. Posted April 17, 2017 Share Posted April 17, 2017 destroy object with destroyElement and set the data to false setElementData(tentCol,"parent",tent) setElementData(tent,"parent",tentCol) setElementData(tentCol,"tent",true) setElementData(tentCol,"vehicle",true) ------------------------------------------------// setElementData(tentCol,"M4A1 CCO",5000) Link to comment
AnnaBelle Posted April 17, 2017 Author Share Posted April 17, 2017 This will only prevent it from being removed Link to comment
AE. Posted April 17, 2017 Share Posted April 17, 2017 don't you want to remove the tent only if the player is an admin ? Link to comment
AnnaBelle Posted April 17, 2017 Author Share Posted April 17, 2017 I managed to do to be removed, but not to remove admin Link to comment
DNL291 Posted April 18, 2017 Share Posted April 18, 2017 I recommend you creating these elements inside a table, so you can easily remove it through command. Also, the player element is wrong in outputChatBox function. Link to comment
Fist Posted April 18, 2017 Share Posted April 18, 2017 (edited) just leave it as it is, you have to modify menu_client.lua file for dayz and then just find where "Remove Tent" function is and make it that it shows only for admins. You also gonna need to add new element data to that tent, something like "admintent" or "armybox" so that you can tell which tent you need to remove that "Remove Tent" function. Edited April 18, 2017 by Fist Link to comment
AnnaBelle Posted April 18, 2017 Author Share Posted April 18, 2017 Someone there can help me, I can not do it. Link to comment
DNL291 Posted April 18, 2017 Share Posted April 18, 2017 (edited) 5 minutes ago, Fist said: just leave it as it is, you have to modify menu_client.lua file for dayz and then just find where "Remove Tent" function is and make it that it shows only for admins. Oh didn't know about that, since I have no experience with DayZ. So, just do what Fist said. Edited April 18, 2017 by DNL291 Link to comment
AnnaBelle Posted April 18, 2017 Author Share Posted April 18, 2017 --Menu_Client if itemName == "tent" then local col = getElementData(getLocalPlayer(),"currentCol") triggerServerEvent("removeTent",getLocalPlayer(),getElementData(col,"parent")) disableMenu() return end --Server function ACLGroupConsole(source) if (isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)),aclGetGroup("Admin"))) then triggerClientEvent(source,"removeTent",source) end end It would be more or less like this? Link to comment
AnnaBelle Posted April 18, 2017 Author Share Posted April 18, 2017 setTimer(updateTenda,43200000,0) Someone helps to simplify this code Link to comment
Fist Posted April 18, 2017 Share Posted April 18, 2017 (edited) @AnnaBelle this should work. BUT anyone won't be able to remove this tent unless you don't add one more check variable if player is admin. You'll have to do a bit more of coding then 'cause you can't not check that from client side. replace this function with your original addCommandHandler("tent",function(thePlayer) if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(thePlayer)),aclGetGroup("Admin"))then local x,y,z = getElementPosition(thePlayer) local xr,yr,zr = getElementRotation(thePlayer) px,py,pz = getElementPosition(thePlayer) prot = getPedRotation(thePlayer) local offsetRot = math.rad(prot+90) local vx = px+1.5*math.cos(offsetRot) local vy = py+1.5*math.sin(offsetRot) local vz = pz+2 local vrot = prot+180 tent = createObject(964,vx,vy,z-1,0,0,vrot) setObjectScale(tent,1.0) tentCol = createColSphere(x,y,z,4) attachElements(tentCol,tent,0,0,0) setElementData(tentCol,"parent",tent) setElementData(tent,"parent",tentCol) setElementData(tentCol,"tent",true) setElementData(tentCol,"admintent",true) setElementData(tentCol,"vehicle",true) ------------------------------------------------// setElementData(tentCol,"M4A1 CCO",5000) ------------------------------------------------// outputChatBox("[TENT]#FFFFFFTent Spawned!",source,46,255,46,true) else outputChatBox("[TENT]#FFFFFFYou are not admin!",source,255,0,0,true) end end) and this in menu_client with your original code of tent --Menu_Client if itemName == "tent" then local col = getElementData(getLocalPlayer(),"currentCol") if getElementData(col,"admintent") then outputChatBox("Sorry, but this tent can only be removed by admin.") disableMenu(); return; end triggerServerEvent("removeTent",getLocalPlayer(),getElementData(col,"parent")) disableMenu() return end Edited April 18, 2017 by Fist 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