Jump to content

[Solved]Problem.


TheMaysTRo

Recommended Posts

Posted (edited)
function plant2 (player) 
 if getElementData( player,"tempdata.farmer", true ) then  
 addCommandHandler ( "plant", plant ) 
   outputChatBox ("you Entred the farm use /plant .",player,0,255,50,false) 
  
 end 
 end 
  
addEventHandler ("onColShapeHit", Cls, plant2) 
  
  
 function dontplant (player) 
  if getElementData( player,"tempdata.farmer", true ) then  
 removeCommandHandler ( "plant") 
    outputChatBox ("you left the farm you can't /plant anymore .",player,0,255,50,false) 
 end 
 end 
  
addEventHandler ("onColShapeLeave", Cls, dontplant) 

when someone enter the colshape he can use plant normaly. and when he left he can't . but if 2 players entred the colshape and one of them left the command handler will be removed for both of them so the one who is in the colshape can't use plant anymore cause the other guy left . any soloution ?

Edited by Guest
Posted
Try to use getElementType.

Or not.

Just add some kind of lock as you did with that "tempdata.farmer", that allows you do use the command handler.

There is no need of removing the handler.

Add it once, and in the plant function you check if the player is allowed to use it.

Posted

Add the command once and use this function to make sure that the player who used the command is inside the col.

isElementWithinColShape 

Posted

i tried all your ideas , ican't do it right ._.

TAPL idea

function plant2 (player) 
 if getElementData( player,"tempdata.farmer", true ) then  
  outputChatBox ("you Entred the farm use /plant .",player,0,255,50,false) 
    if  isElementWithinColShape (player,Cls) then 
 addCommandHandler ( "plant", plant ) 
 end 
 end 
 end 
  
addEventHandler ("onColShapeHit", Cls, plant2) 
  
  
 function dontplant (player) 
  if getElementData( player,"tempdata.farmer", true ) then  
      outputChatBox ("you left the farm you can't /plant anymore .",player,0,255,50,false) 
 end 
 end 
  
addEventHandler ("onColShapeLeave", Cls, dontplant) 

what's wrong ?

(i can /plant when i leave the colshape =

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