Best-Killer Posted November 2, 2016 Share Posted November 2, 2016 (edited) 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 November 2, 2016 by Best-Killer Link to comment
Mr.Loki Posted November 2, 2016 Share Posted November 2, 2016 getObjectByHit( player ) is a custom function and should be defined in the script. Do you get any errors when starting the resource? Link to comment
Best-Killer Posted November 2, 2016 Author Share Posted November 2, 2016 No i didn't get any other error when i start the resource Link to comment
Mr.Loki Posted November 2, 2016 Share Posted November 2, 2016 Well the getObjectByHit( ) function is missing from the script. Maybe you removed it by mistake or something? Link to comment
Best-Killer Posted November 2, 2016 Author Share Posted November 2, 2016 no , i still have just error :Line 38 , attempt to all global 'getObjectByHit' (a nil value) Link to comment
Mr.Loki Posted November 2, 2016 Share Posted November 2, 2016 (edited) because 'getObjectByHit' isn't defined in your code. Edited November 2, 2016 by loki2143 Link to comment
Best-Killer Posted November 2, 2016 Author Share Posted November 2, 2016 ah guys all right 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
pa3ck Posted November 2, 2016 Share Posted November 2, 2016 Please don't *bump* your post, it's not an advertising website and use LUA tags when posting LUA code. Change line 29 to this: for i, v in ipairs( getElementsByType( 'colshape', rRoot ) ) do Link to comment
Best-Killer Posted November 2, 2016 Author Share Posted November 2, 2016 0 errors but the object didn't remove and the marker removed 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