Jump to content

destory ojbect/marker


Best-Killer

Recommended Posts

addEvent( 'Createatm', true )
addEventHandler( 'Createatm', root, 
function( X, Y, Z , R)
if getPedOccupiedVehicle( source ) then Z = Z else Z = Z - 1 end
local AllMarker = executeSQLQuery( "SELECT * FROM tessst" )
local AllObject = executeSQLQuery( "SELECT * FROM tessst" )
id = #AllMarker + 1
obid = #AllObject + 1
executeSQLQuery( "INSERT INTO tessst ( posX, posY, posZ,50,205,50, objX, objY, objZ, 0,0,Rotation ,ID ) VALUES ( "..X..", "..Y..", "..Z..","..X..", "..Y..", "..Z..","..R..", "..id..","..obid..")" )
local marker = createMarker( X, Y, Z, 'cylinder', 1.5, 50,205,50, 255 )
local object = createObject(2942, X, Y, Z+0.70, 0, 0, R)
setElementData( object, 'id', id )
setElementData( marker, 'id', obid )
outputChatBox( "ATM Has Created", source, 255, 255, 0 )
end
)

addEventHandler( 'onMarkerHit', rRoot, function( p , acc )
    if ( p and getElementType ( p ) == 'player' and not isPedInVehicle ( p ) ) then
		if ( getElementInterior ( p ) == getElementInterior ( source ) and getElementDimension ( p ) == getElementDimension ( source )  ) then
			local acc = getPlayerAccount ( p )
			if ( isGuestAccount ( acc ) ) then return false end
			local acc = getAccountName ( acc )
			
			if ( not doesBankAccountExist ( acc ) ) then
				createBankAccount ( acc )
			end
	triggerClientEvent(p,"markerhit",p,accounts[acc],acc,source)
				
      end
	  end
	  end
)

addCommandHandler( cmd, function(player, Command)
    if isObjectInACLGroup( 'user.'..getAccountName( getPlayerAccount( player ) ), aclGetGroup( allowedGroup ) ) then
		local mrker = getMarkerByHit( player )
		local objct = getObjectByHit( player )
		if mrker then
		if objct then
			local id = tonumber ( getElementData( mrker, 'id') or 0 )
			local obid = tonumber ( getElementData( objct, 'id') or 0 )
			if id == 0 then return end
			if obid == 0 then return end
			if executeSQLQuery("DELETE FROM `tessst` WHERE `ID`=?", id) then
			if executeSQLQuery("DELETE FROM `tessst` WHERE `ID`=?", obid) then
				destroyElement( mrker )
				destroyElement( objct )
				outputChatBox( "ATM Has Deleted", player, 255, 255, 0 )
			else
				outputChatBox( "error", player, 255, 255, 0 )		
			end
			end
			end
		end
	else
		outputChatBox( "Access denied", player, 255, 255, 0 )	
	end	
end
)


function getMarkerByHit( plr )
  for i, v in ipairs( getElementsByType( 'marker', rRoot ) ) do
    if isElementWithinMarker(plr, v) then
      return v
    end
  end
  return false,outputChatBox( "Error: Please enter the marker", plr, 255, 255, 0 )
end

error :Line 38 ,  attempt to all global 'getObjectByHit' (a nil value) 

AllowedGroup , CMD work fine 

Edited by Best-Killer
Link to comment

ah guys all right xD 

i tried with this now

addCommandHandler( cmd, function(player, Command)
    if isObjectInACLGroup( 'user.'..getAccountName( getPlayerAccount( player ) ), aclGetGroup( allowedGroup ) ) then
		local mrker = getMarkerByHit( player )
		local objct = getObjectByHit( player )
		if mrker then
		if objct then
			local id = tonumber ( getElementData( mrker, 'id') or 0 )
			local obid = tonumber ( getElementData( objct, 'id') or 0 )
			if id == 0 then return end
			if obid == 0 then return end
			if executeSQLQuery("DELETE FROM `tessst` WHERE `ID`=?", id) then
			if executeSQLQuery("DELETE FROM `tessst` WHERE `ID`=?", obid) then
				destroyElement( mrker )
				destroyElement( objct )
				outputChatBox( "ATM Has Deleted", player, 255, 255, 0 )
			else
				outputChatBox( "error", player, 255, 255, 0 )		
			end
			end
			end
		end
	else
		outputChatBox( "Access denied", player, 255, 255, 0 )	
	end	
end
)

function getObjectByHit( plr )
  for i, v in ipairs( getElementsByType( 'object', rRoot ) ) do
    if isElementWithinColShape(plr, v) then
      return v
    end
  end
  return false,outputChatBox( "Error: Please enter the marker", plr, 255, 255, 0 )
end

function getMarkerByHit( plr )
  for i, v in ipairs( getElementsByType( 'marker', rRoot ) ) do
    if isElementWithinMarker(plr, v) then
      return v
    end
  end
  return false,outputChatBox( "Error: Please enter the marker", plr, 255, 255, 0 )
end

bad argument @'isElementWithinColShape' [Expected colshape at argument 2, go object]

any help pls ?

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...