-snowman- Posted February 4, 2012 Posted February 4, 2012 i was just trying my first script to plant a pot and after a time it destroys and spawns weed in its place but i cant get it to work here is the code, any help would be good function plantWeedForPlayer(thePlayer, command) local x,y,z = getElementPosition(thePlayer) x = x + 1 z = z - 0.5 local weed = createObject(2241,x,y,z) setTimer(destroyElement, 5000, 1, weed ) addEventHandler ("onElementDestroy", weed, growWeed) end addCommandHandler("plantseeds", plantWeedForPlayer) function growWeed (thePlayer) local x, y, z = getElementPosition ( weed ) grass = createObject ( 3409, x, y, z ) z = z - 1 end
Kenix Posted February 4, 2012 Posted February 4, 2012 Try Server side. function plantWeedForPlayer( thePlayer, command ) local x,y,z = getElementPosition( thePlayer ) local weed = createObject( 2241,x + 1,y,z - 0.5 ) setTimer( destroyElement, 5000, 1, weed ) addEventHandler ("onElementDestroy", weed, growWeed) end addCommandHandler( "plantseeds", plantWeedForPlayer ) function growWeed ( ) local x, y, z = getElementPosition ( source ) grass = createObject ( 3409, x, y, z - 1 ) end Use /debugscript 3.
-snowman- Posted February 4, 2012 Author Posted February 4, 2012 yea that worked didnt see my mistake there but ty
-snowman- Posted February 4, 2012 Author Posted February 4, 2012 hi again im tryin to add line that checks if the player has seeds and if they dont to not let them plant the line knows i dont have the item and send me the message but it still plants, how would i stop it from planting if player has not got the item function plantWeedForPlayer( thePlayer, command ) if not(exports.global:hasItem(thePlayer, 49)) then outputChatBox("You need seeds to plant.", thePlayer, 255, 0, 0) local x,y,z = getElementPosition( thePlayer ) x = x + 1 z = z - 0.5 local weed = createObject( 2241,x,y,z ) setTimer( destroyElement, 1440000, 1, weed ) addEventHandler ("onElementDestroy", weed, growWeed) end end addCommandHandler( "plantseeds", plantWeedForPlayer ) function growWeed ( ) local x, y, z = getElementPosition ( source ) z = z - 1 grass = createObject ( 3409, x, y, z ) end
Castillo Posted February 4, 2012 Posted February 4, 2012 function plantWeedForPlayer( thePlayer, command ) if not (exports.global:hasItem(thePlayer, 49)) then outputChatBox("You need seeds to plant.", thePlayer, 255, 0, 0) else local x,y,z = getElementPosition( thePlayer ) x = x + 1 z = z - 0.5 local weed = createObject( 2241,x,y,z ) setTimer( destroyElement, 1440000, 1, weed ) addEventHandler ("onElementDestroy", weed, growWeed) end end addCommandHandler( "plantseeds", plantWeedForPlayer ) function growWeed ( ) local x, y, z = getElementPosition ( source ) z = z - 1 grass = createObject ( 3409, x, y, z ) end
-snowman- Posted February 4, 2012 Author Posted February 4, 2012 thanks man im new to lua so i didnt see that error
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