TheMaysTRo Posted September 2, 2014 Share Posted September 2, 2014 (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 September 2, 2014 by Guest Link to comment
iPrestege Posted September 2, 2014 Share Posted September 2, 2014 (edited) Try to use getElementType. Edited September 2, 2014 by Guest Link to comment
TheMaysTRo Posted September 2, 2014 Author Share Posted September 2, 2014 Try to use getElementType. what do you mean ? i get the type and if its player then what ? Link to comment
Bonsai Posted September 2, 2014 Share Posted September 2, 2014 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. Link to comment
iPrestege Posted September 2, 2014 Share Posted September 2, 2014 Check my post again. Link to comment
Bonsai Posted September 2, 2014 Share Posted September 2, 2014 Check my post again. You made it even worse. Checking the type of a not existing element variable. Also, its not helpful at all. Link to comment
TAPL Posted September 2, 2014 Share Posted September 2, 2014 Add the command once and use this function to make sure that the player who used the command is inside the col. isElementWithinColShape Link to comment
TheMaysTRo Posted September 2, 2014 Author Share Posted September 2, 2014 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 = Link to comment
Bonsai Posted September 2, 2014 Share Posted September 2, 2014 ... You are supposed to check that INSIDE the plant function! Link to comment
TheMaysTRo Posted September 2, 2014 Author Share Posted September 2, 2014 Thanks guys Worked . Special Thanks to TAPL and Bonsai 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