Jump to content

[HELP -ME]Tent remove


AnnaBelle

Recommended Posts

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

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

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 by Fist
Link to comment
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 by DNL291
Link to comment
--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 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 by Fist
Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...