lolek123 Posted August 25, 2012 Share Posted August 25, 2012 Client Side: function training(localPlayer, command) if (isElementWithinMarker(localPlayer, myMarker) == true) then local x,y,z = getPedBonePosition(localPlayer, 25) attachElements( object(2916), localPlayer, x,y,z) elseif (isElementWithinMarker(localPlayer, myMarker) == false) then outputChatBox("nope", localPlayer) end end addCommandHandler("train", training) Server Side: function CheckMyObject(res) if res==getThisResource() then for _,object in ipairs(getElementsByType("object")) do if getElementModel(object)==2916 then local x,y,z=getElementPosition(object) local int=getElementInterior(object) local dim=getElementDimension(object) myMarker = createMarker(x,y,z,"cylinder",2.0,255,0,0,125) setElementInterior(myMarker,int) setElementDimension(myMarker,dim) end end end end addEventHandler("onResourceStart",getRootElement(),CheckMyObject) I'm getting bad argument error each time I type in the command, can someone tell me if I have to export "myMarker" somehow from script.lua to client.lua or what? Link to comment
Anderl Posted August 25, 2012 Share Posted August 25, 2012 Client-side: addEventHandler( 'onClientResourceStart', resourceRoot, function( pRes ) for i,v in ipairs( getElementsByType( 'object' ) ) do if( getElementModel( v ) == 2916 ) then local iX, iY, iZ = getElementPosition( v ) local iInt = getElementInterior( v ) local iDim = getElementDimension( v ) myMarker = createMarker( iX, iY, iZ, 'cylinder', 2.0, 255, 0, 0, 125 ) setElementInterior( myMarker, iInt ) setElementDimension( myMarker, iDim ) end end end ) addCommandHandler( 'train', function( c ) local p = localPlayer if( isElementWithinMarker( p, myMarker ) ) then local iX, iY, iZ = getPedBonePosition( p, 25 ) attachElements( 2916, p, iX, iY, iZ ) else outputChatBox( 'Nope.', p ) end end ) Not tested. Link to comment
lolek123 Posted August 25, 2012 Author Share Posted August 25, 2012 Could you also make it actually pick up the object, it has a bad argument on "attachElements" and I dont know how to specify the object that he has to pick up. Maybe I need to give each of the elements with model ID 2916 their own ID with setElementID? Link to comment
lolek123 Posted September 1, 2012 Author Share Posted September 1, 2012 Could you also make it actually pick up the object, it has a bad argument on "attachElements" and I dont know how to specify the object that he has to pick up. Maybe I need to give each of the elements with model ID 2916 their own ID with setElementID? Anyone? Link to comment
Castillo Posted September 1, 2012 Share Posted September 1, 2012 addEventHandler( 'onClientResourceStart', resourceRoot, function( pRes ) for i,v in ipairs( getElementsByType( 'object' ) ) do if( getElementModel( v ) == 2916 ) then local iX, iY, iZ = getElementPosition( v ) local iInt = getElementInterior( v ) local iDim = getElementDimension( v ) myMarker = createMarker( iX, iY, iZ, 'cylinder', 2.0, 255, 0, 0, 125 ) setElementInterior( myMarker, iInt ) setElementDimension( myMarker, iDim ) end end end ) addCommandHandler( 'train', function( c ) local p = localPlayer if( isElementWithinMarker( p, myMarker ) ) then local iX, iY, iZ = getPedBonePosition( p, 25 ) object = createObject ( 2916, iX, iY, iZ ) attachElements( object, p, iX, iY, iZ ) else outputChatBox( 'Nope.', p ) end end ) Link to comment
lolek123 Posted September 2, 2012 Author Share Posted September 2, 2012 addEventHandler( 'onClientResourceStart', resourceRoot, function( pRes ) for i,v in ipairs( getElementsByType( 'object' ) ) do if( getElementModel( v ) == 2916 ) then local iX, iY, iZ = getElementPosition( v ) local iInt = getElementInterior( v ) local iDim = getElementDimension( v ) myMarker = createMarker( iX, iY, iZ, 'cylinder', 2.0, 255, 0, 0, 125 ) setElementInterior( myMarker, iInt ) setElementDimension( myMarker, iDim ) end end end ) addCommandHandler( 'train', function( c ) local p = localPlayer if( isElementWithinMarker( p, myMarker ) ) then local iX, iY, iZ = getPedBonePosition( p, 25 ) object = createObject ( 2916, iX, iY, iZ ) attachElements( object, p, iX, iY, iZ ) else outputChatBox( 'Nope.', p ) end end ) And if I wanted it to pick up the object that is there on the map, instead of creating a new one, would that be doable? 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