Jump to content

i need help


-snowman-

Recommended Posts

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     
     

Link to comment

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.

Link to comment

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     

Link to comment
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 

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