gokalpfirat Posted June 16, 2011 Share Posted June 16, 2011 (edited) function ResourceStart() marker = createMarker ( 1449.3040771484, -2937.9020996094, 2.9447371959686, "cylinder", 1, 255, 255, 0) setElementData(getLocalPlayer(),"all","0") setElementData(getLocalPlayer(),"tea","0") setElementData(getLocalPlayer(),"water","0") end addEventHandler ( "onResourceStart", getRootElement(), ResourceStart ) function MarkerHit( hitElement, matchingDimension ) if getElementType( hitElement ) == "player" then outputChatBox( "You are now in my cafe.", source, 255, 255, 0 ) outputChatBox( "If you want drink water use /water .", source, 255, 255, 0 ) outputChatBox( "If you want drink tea use /tea .", source, 255, 255, 0 ) addCommandHandler ( "water", water ) addCommandHandler ( "tea", tea ) end end addEventHandler( "onMarkerHit", marker, MarkerHit ) function markerLeave( leaveElement, matchingDimension ) if getElementType( leaveElement ) == "player" then outputChatBox ( getPlayerName( thePlayer).."has left the cafe.", getRootElement(), 255, 255, 0 ) removeCommandHandler ("water", water) removeCommandHandler ("tea", tea) end end addEventHandler( "onMarkerLeave", marker, markerLeave ) function water ( thePlayer, command ) outputChatBox( getPlayerName( thePlayer).."drunk water.", 255, 255, 0 ) setElementData ( thePlayer ,"water",tostring(tonumber(getElementData(thePlayer,"water"))+1)) end function tea ( thePlayer, command ) outputChatBox( getPlayerName( thePlayer).."drunk tea.", 255, 255, 0 ) setElementData ( thePlayer ,"tea",tostring(tonumber(getElementData(thePlayer,"tea"))+1)) end function all ( thePlayer, command ) local bira = tostring(tonumber(getElementData(thePlayer,"tea"))) local raki = tostring(tonumber(getElementData(thePlayer,"water"))) local toplam = tostring(tonumber(getElementData(thePlayer,"tea"))) + tostring(tonumber(getElementData(thePlayer,"water"))) outputChatBox( getPlayerName( thePlayer).."drunks"..toplam..".["..water.."water"..tea.."tea]", 255, 255, 0 ) end addCommandHandler ( "all", all ) Its server-side. It doesn't works can you help? Edited June 16, 2011 by Guest Link to comment
JR10 Posted June 16, 2011 Share Posted June 16, 2011 (edited) 1. use [lua.][/lua] tags. 2. tell us what's the problem dont just say "it doesn't work". Its server-side. It doesn't works can you help? How it's server side when you have setElementData(getLocalPlayer(),"all","0") setElementData(getLocalPlayer(),"tea","0") setElementData(getLocalPlayer(),"water","0") getLocalPlayer() is a client side function, you should do: function ResourceStart() marker = createMarker ( 1449.3040771484, -2937.9020996094, 2.9447371959686, "cylinder", 1, 255, 255, 0) for i, v in ipairs(getElementsByType('player')) do setElementData(v,"all","0") setElementData(v,"tea","0") setElementData(v,"water","0") end end addEventHandler ( "onResourceStart", getRootElement(), ResourceStart ) Edited June 16, 2011 by Guest Link to comment
gokalpfirat Posted June 16, 2011 Author Share Posted June 16, 2011 Now i use lua tags. When i hit marker it doesnt matters? Link to comment
JR10 Posted June 16, 2011 Share Posted June 16, 2011 See my post again , nvm. here it is: Its server-side. It doesn't works can you help? How it's server side when you have setElementData(getLocalPlayer(),"all","0") setElementData(getLocalPlayer(),"tea","0") setElementData(getLocalPlayer(),"water","0") getLocalPlayer() is a client side function, you should do: function ResourceStart() marker = createMarker ( 1449.3040771484, -2937.9020996094, 2.9447371959686, "cylinder", 1, 255, 255, 0) for i, v in ipairs(getElementsByType('player')) do setElementData(v,"all","0") setElementData(v,"tea","0") setElementData(v,"water","0") end end addEventHandler ( "onResourceStart", getRootElement(), ResourceStart ) Also you got getRootElement() in onResourceStart in this way it will trigger it on any resource start should be: addEventHandler ( "onResourceStart", resourceRoot, ResourceStart ) Link to comment
gokalpfirat Posted June 16, 2011 Author Share Posted June 16, 2011 Now when i hit marker outputChatbox dont works. Link to comment
JR10 Posted June 16, 2011 Share Posted June 16, 2011 function MarkerHit( hitElement, matchingDimension ) if getElementType( hitElement ) == "player" then outputChatBox( "You are now in my cafe.", source, 255, 255, 0 ) outputChatBox( "If you want drink water use /water .", source, 255, 255, 0 ) outputChatBox( "If you want drink tea use /tea .", source, 255, 255, 0 ) addCommandHandler ( "water", water ) addCommandHandler ( "tea", tea ) end You are talking to the marker function MarkerHit( hitElement, matchingDimension ) if getElementType( hitElement ) == "player" then outputChatBox( "You are now in my cafe.", hitElement, 255, 255, 0 ) outputChatBox( "If you want drink water use /water .", hitElement, 255, 255, 0 ) outputChatBox( "If you want drink tea use /tea .", hitElement, 255, 255, 0 ) addCommandHandler ( "water", water ) addCommandHandler ( "tea", tea ) end Link to comment
gokalpfirat Posted June 16, 2011 Author Share Posted June 16, 2011 I test it again but it doesnt works i see marker when i hit dont matter why i can give you a ss if you want. Link to comment
JR10 Posted June 16, 2011 Share Posted June 16, 2011 do this: function ResourceStart() marker = createMarker ( 1449.3040771484, -2937.9020996094, 2.9447371959686, "cylinder", 1, 255, 255, 0) for i, v in ipairs(getElementsByType('player')) do setElementData(v,"all","0") setElementData(v,"tea","0") setElementData(v,"water","0") end addEventHandler( "onMarkerHit", marker, MarkerHit ) addEventHandler( "onMarkerLeave", marker, markerLeave ) end addEventHandler ( "onResourceStart", getRootElement(), ResourceStart ) function MarkerHit( hitElement, matchingDimension ) if getElementType( hitElement ) == "player" then function MarkerHit( hitElement, matchingDimension ) if getElementType( hitElement ) == "player" then outputChatBox( "You are now in my cafe.", hitElement, 255, 255, 0 ) outputChatBox( "If you want drink water use /water .", hitElement, 255, 255, 0 ) outputChatBox( "If you want drink tea use /tea .", hitElement, 255, 255, 0 ) addCommandHandler ( "water", water ) addCommandHandler ( "tea", tea ) end end end function markerLeave( leaveElement, matchingDimension ) if getElementType( leaveElement ) == "player" then outputChatBox ( getPlayerName( thePlayer).."has left the cafe.", getRootElement(), 255, 255, 0 ) removeCommandHandler ("water", water) removeCommandHandler ("tea", tea) end end function water ( thePlayer, command ) outputChatBox( getPlayerName( thePlayer).."drunk water.", 255, 255, 0 ) setElementData ( thePlayer ,"water",tostring(tonumber(getElementData(thePlayer,"water"))+1)) end function tea ( thePlayer, command ) outputChatBox( getPlayerName( thePlayer).."drunk tea.", 255, 255, 0 ) setElementData ( thePlayer ,"tea",tostring(tonumber(getElementData(thePlayer,"tea"))+1)) end function all ( thePlayer, command ) local bira = tostring(tonumber(getElementData(thePlayer,"tea"))) local raki = tostring(tonumber(getElementData(thePlayer,"water"))) local toplam = tostring(tonumber(getElementData(thePlayer,"tea"))) + tostring(tonumber(getElementData(thePlayer,"water"))) outputChatBox( getPlayerName( thePlayer).."drunks"..toplam..".["..water.."water"..tea.."tea]", 255, 255, 0 ) end addCommandHandler ( "all", all ) Link to comment
Kenix Posted June 16, 2011 Share Posted June 16, 2011 (edited) addEventHandler('onMarkerHit',getRootElement(), function( hitElement, matchingDimension ) if getElementType( hitElement ) == "player" then outputChatBox( "You are now in my cafe.", source, 255, 255, 0 ) outputChatBox( "If you want drink water use /water .", source, 255, 255, 0 ) outputChatBox( "If you want drink tea use /tea .", source, 255, 255, 0 ) addCommandHandler ( "water", water ) addCommandHandler ( "tea", tea ) end end) Edited June 16, 2011 by Guest Link to comment
gokalpfirat Posted June 16, 2011 Author Share Posted June 16, 2011 (edited) It doesnt works look Edited June 16, 2011 by Guest Link to comment
JR10 Posted June 16, 2011 Share Posted June 16, 2011 volk , look at your code again source instead of hitElement and that's not the problem, he had a bad arguments at the event handlers, this should work: function ResourceStart() marker = createMarker ( 1449.3040771484, -2937.9020996094, 2.9447371959686, "cylinder", 1, 255, 255, 0) for i, v in ipairs(getElementsByType('player')) do setElementData(v,"all","0") setElementData(v,"tea","0") setElementData(v,"water","0") end addEventHandler( "onMarkerHit", marker, MarkerHit ) addEventHandler( "onMarkerLeave", marker, markerLeave ) end addEventHandler ( "onResourceStart", resourceRoot, ResourceStart ) function MarkerHit( hitElement, matchingDimension ) if getElementType( hitElement ) == "player" then function MarkerHit( hitElement, matchingDimension ) if getElementType( hitElement ) == "player" then outputChatBox( "You are now in my cafe.", hitElement, 255, 255, 0 ) outputChatBox( "If you want drink water use /water .", hitElement, 255, 255, 0 ) outputChatBox( "If you want drink tea use /tea .", hitElement, 255, 255, 0 ) addCommandHandler ( "water", water ) addCommandHandler ( "tea", tea ) end end end function markerLeave( leaveElement, matchingDimension ) if getElementType( leaveElement ) == "player" then outputChatBox ( getPlayerName( thePlayer).."has left the cafe.", getRootElement(), 255, 255, 0 ) removeCommandHandler ("water", water) removeCommandHandler ("tea", tea) end end function water ( thePlayer, command ) outputChatBox( getPlayerName( thePlayer).."drunk water.", 255, 255, 0 ) setElementData ( thePlayer ,"water",tostring(tonumber(getElementData(thePlayer,"water"))+1)) end function tea ( thePlayer, command ) outputChatBox( getPlayerName( thePlayer).."drunk tea.", 255, 255, 0 ) setElementData ( thePlayer ,"tea",tostring(tonumber(getElementData(thePlayer,"tea"))+1)) end function all ( thePlayer, command ) local bira = tostring(tonumber(getElementData(thePlayer,"tea"))) local raki = tostring(tonumber(getElementData(thePlayer,"water"))) local toplam = tostring(tonumber(getElementData(thePlayer,"tea"))) + tostring(tonumber(getElementData(thePlayer,"water"))) outputChatBox( getPlayerName( thePlayer).."drunks"..toplam..".["..water.."water"..tea.."tea]", 255, 255, 0 ) end addCommandHandler ( "all", all ) Link to comment
Kenix Posted June 16, 2011 Share Posted June 16, 2011 I use mobile phone dude full code function ResourceStart() marker = createMarker ( 1449.3040771484, -2937.9020996094, 2.9447371959686, "cylinder", 1, 255, 255, 0) for i, v in ipairs(getElementsByType('player')) do setElementData(v,"all","0") setElementData(v,"tea","0") setElementData(v,"water","0") end end addEventHandler ( "onResourceStart", resourceRoot, ResourceStart ) function MarkerHit( hitElement, matchingDimension ) if getElementType( hitElement ) == "player" then outputChatBox( "You are now in my cafe.", hitElement, 255, 255, 0 ) outputChatBox( "If you want drink water use /water .", hitElement, 255, 255, 0 ) outputChatBox( "If you want drink tea use /tea .", hitElement, 255, 255, 0 ) addCommandHandler ( "water", water ) addCommandHandler ( "tea", tea ) end end addEventHandler( "onMarkerHit", marker, MarkerHit ) function markerLeave( leaveElement, matchingDimension ) if getElementType( leaveElement ) == "player" then outputChatBox ( getPlayerName( thePlayer).."has left the cafe.", getRootElement(), 255, 255, 0 ) removeCommandHandler ("water", water) removeCommandHandler ("tea", tea) end end addEventHandler( "onMarkerLeave", marker, markerLeave ) function water ( thePlayer, command ) outputChatBox( getPlayerName( thePlayer).."drunk water.", 255, 255, 0 ) setElementData ( thePlayer ,"water",tostring(tonumber(getElementData(thePlayer,"water"))+1)) end function tea ( thePlayer, command ) outputChatBox( getPlayerName( thePlayer).."drunk tea.", 255, 255, 0 ) setElementData ( thePlayer ,"tea",tostring(tonumber(getElementData(thePlayer,"tea"))+1)) end function all ( thePlayer, command ) local bira = tostring(tonumber(getElementData(thePlayer,"tea"))) local raki = tostring(tonumber(getElementData(thePlayer,"water"))) local toplam = tostring(tonumber(getElementData(thePlayer,"tea"))) + tostring(tonumber(getElementData(thePlayer,"water"))) outputChatBox( getPlayerName( thePlayer).."drunks"..toplam..".["..water.."water"..tea.."tea]", 255, 255, 0 ) end addCommandHandler ( "all", all ) Link to comment
JR10 Posted June 16, 2011 Share Posted June 16, 2011 Wont work because it will give warnings at the 2 addEventHandlers for markers they must be put inside the onResourceStart function. function ResourceStart() marker = createMarker ( 1449.3040771484, -2937.9020996094, 2.9447371959686, "cylinder", 1, 255, 255, 0) for i, v in ipairs(getElementsByType('player')) do setElementData(v,"all","0") setElementData(v,"tea","0") setElementData(v,"water","0") addEventHandler( "onMarkerHit", marker, MarkerHit ) addEventHandler( "onMarkerLeave", marker, markerLeave ) end end addEventHandler ( "onResourceStart", resourceRoot, ResourceStart ) function MarkerHit( hitElement, matchingDimension ) if getElementType( hitElement ) == "player" then outputChatBox( "You are now in my cafe.", hitElement, 255, 255, 0 ) outputChatBox( "If you want drink water use /water .", hitElement, 255, 255, 0 ) outputChatBox( "If you want drink tea use /tea .", hitElement, 255, 255, 0 ) addCommandHandler ( "water", water ) addCommandHandler ( "tea", tea ) end end function markerLeave( leaveElement, matchingDimension ) if getElementType( leaveElement ) == "player" then outputChatBox ( getPlayerName( thePlayer).."has left the cafe.", getRootElement(), 255, 255, 0 ) removeCommandHandler ("water", water) removeCommandHandler ("tea", tea) end end function water ( thePlayer, command ) outputChatBox( getPlayerName( thePlayer).."drunk water.", 255, 255, 0 ) setElementData ( thePlayer ,"water",tostring(tonumber(getElementData(thePlayer,"water"))+1)) end function tea ( thePlayer, command ) outputChatBox( getPlayerName( thePlayer).."drunk tea.", 255, 255, 0 ) setElementData ( thePlayer ,"tea",tostring(tonumber(getElementData(thePlayer,"tea"))+1)) end function all ( thePlayer, command ) local bira = tostring(tonumber(getElementData(thePlayer,"tea"))) local raki = tostring(tonumber(getElementData(thePlayer,"water"))) local toplam = tostring(tonumber(getElementData(thePlayer,"tea"))) + tostring(tonumber(getElementData(thePlayer,"water"))) outputChatBox( getPlayerName( thePlayer).."drunks"..toplam..".["..water.."water"..tea.."tea]", 255, 255, 0 ) end addCommandHandler ( "all", all ) Link to comment
gokalpfirat Posted June 16, 2011 Author Share Posted June 16, 2011 JR10 yours i think works but marker doesnt visible i cant see x,y,z is true. Link to comment
JR10 Posted June 16, 2011 Share Posted June 16, 2011 Hmm,is it in an interior?, because i tested it the marker is visible but its in the sea Link to comment
gokalpfirat Posted June 16, 2011 Author Share Posted June 16, 2011 It works but /all command dont works. Link to comment
Castillo Posted June 16, 2011 Share Posted June 16, 2011 function ResourceStart() marker = createMarker ( 1449.3040771484, -2937.9020996094, 2.9447371959686, "cylinder", 1, 255, 255, 0) for i, v in ipairs(getElementsByType('player')) do setElementData(v,"all","0") setElementData(v,"tea","0") setElementData(v,"water","0") addEventHandler( "onMarkerHit", marker, MarkerHit ) addEventHandler( "onMarkerLeave", marker, markerLeave ) end end addEventHandler ( "onResourceStart", resourceRoot, ResourceStart ) function MarkerHit( hitElement, matchingDimension ) if getElementType( hitElement ) == "player" then outputChatBox( "You are now in my cafe.", hitElement, 255, 255, 0 ) outputChatBox( "If you want drink water use /water .", hitElement, 255, 255, 0 ) outputChatBox( "If you want drink tea use /tea .", hitElement, 255, 255, 0 ) addCommandHandler ( "water", water ) addCommandHandler ( "tea", tea ) end end function markerLeave( leaveElement, matchingDimension ) if getElementType( leaveElement ) == "player" then outputChatBox ( getPlayerName( thePlayer).."has left the cafe.", getRootElement(), 255, 255, 0 ) removeCommandHandler ("water", water) removeCommandHandler ("tea", tea) end end function water ( thePlayer, command ) outputChatBox( getPlayerName( thePlayer).."drunk water.", 255, 255, 0 ) setElementData ( thePlayer ,"water",tostring(tonumber(getElementData(thePlayer,"water"))+1)) end function tea ( thePlayer, command ) outputChatBox( getPlayerName( thePlayer).."drunk tea.", 255, 255, 0 ) setElementData ( thePlayer ,"tea",tostring(tonumber(getElementData(thePlayer,"tea"))+1)) end function all ( thePlayer, command ) local bira = tostring(tonumber(getElementData(thePlayer,"tea"))) local raki = tostring(tonumber(getElementData(thePlayer,"water"))) local toplam = tostring(tonumber(getElementData(thePlayer,"tea"))) + tostring(tonumber(getElementData(thePlayer,"water"))) outputChatBox( getPlayerName( thePlayer).."drunks"..toplam..".["..raki.."water"..bira.."tea]", 255, 255, 0 ) end addCommandHandler ( "all", all ) Next time use the debugscript to search for errors, you had an error. Error was: attempt to concatenate global 'tea' (a function value) Link to comment
JR10 Posted June 16, 2011 Share Posted June 16, 2011 Also you made a mistake at outputChatBox here: outputChatBox( getPlayerName( thePlayer).."drunk tea.", 255, 255, 0 ) outputChatBox( getPlayerName( thePlayer).."drunk water.", 255, 255, 0 ) outputChatBox( getPlayerName( thePlayer).."drunks"..toplam..".["..water.."water"..tea.."tea]", 255, 255, 0 ) Should be outputChatBox( getPlayerName( thePlayer).."drunk tea.", root, 255, 255, 0 ) outputChatBox( getPlayerName( thePlayer).."drunk water.", root, 255, 255, 0 ) outputChatBox( getPlayerName( thePlayer).."drunks"..toplam..".["..water.."water"..tea.."tea]", root, 255, 255, 0 ) Link to comment
gokalpfirat Posted June 17, 2011 Author Share Posted June 17, 2011 Solidsnake yours is not working JR10 yours is too. Link to comment
JR10 Posted June 17, 2011 Share Posted June 17, 2011 Castillo's one is not working because you had a mistake in the outputChatBox but i fixed it in mine so it should work. here: function ResourceStart() marker = createMarker ( 1449.3040771484, -2937.9020996094, 2.9447371959686, "cylinder", 1, 255, 255, 0) for i, v in ipairs(getElementsByType('player')) do setElementData(v,"all","0") setElementData(v,"tea","0") setElementData(v,"water","0") addEventHandler( "onMarkerHit", marker, MarkerHit ) addEventHandler( "onMarkerLeave", marker, markerLeave ) end end addEventHandler ( "onResourceStart", resourceRoot, ResourceStart ) function MarkerHit( hitElement, matchingDimension ) if getElementType( hitElement ) == "player" then outputChatBox( "You are now in my cafe.", hitElement, 255, 255, 0 ) outputChatBox( "If you want drink water use /water .", hitElement, 255, 255, 0 ) outputChatBox( "If you want drink tea use /tea .", hitElement, 255, 255, 0 ) addCommandHandler ( "water", water ) addCommandHandler ( "tea", tea ) end end function markerLeave( leaveElement, matchingDimension ) if getElementType( leaveElement ) == "player" then outputChatBox ( getPlayerName( thePlayer).."has left the cafe.", getRootElement(), 255, 255, 0 ) removeCommandHandler ("water", water) removeCommandHandler ("tea", tea) end end function water ( thePlayer, command ) outputChatBox( getPlayerName( thePlayer).."drunk water.", root, 255, 255, 0 ) setElementData ( thePlayer ,"water",tostring(tonumber(getElementData(thePlayer,"water"))+1)) end function tea ( thePlayer, command ) outputChatBox( getPlayerName( thePlayer).."drunk tea.", root, 255, 255, 0 ) setElementData ( thePlayer ,"tea",tostring(tonumber(getElementData(thePlayer,"tea"))+1)) end function all ( thePlayer, command ) local bira = tostring(tonumber(getElementData(thePlayer,"tea"))) local raki = tostring(tonumber(getElementData(thePlayer,"water"))) local toplam = tostring(tonumber(getElementData(thePlayer,"tea"))) + tostring(tonumber(getElementData(thePlayer,"water"))) outputChatBox( getPlayerName( thePlayer).."drunks"..toplam..".["..raki.."water"..bira.."tea]", root, 255, 255, 0 ) end addCommandHandler ( "all", all ) Link to comment
gokalpfirat Posted June 17, 2011 Author Share Posted June 17, 2011 Now im testing and markerleave function doesnt works. Link to comment
JR10 Posted June 17, 2011 Share Posted June 17, 2011 function markerLeave( leaveElement, matchingDimension ) if getElementType( leaveElement ) == "player" then outputChatBox ( getPlayerName( leaveElement).."has left the cafe.", getRootElement(), 255, 255, 0 ) removeCommandHandler ("water", water) removeCommandHandler ("tea", tea) end end And please do /debugscript 3 ingame you will figure out the problems yourself. Link to comment
gokalpfirat Posted June 17, 2011 Author Share Posted June 17, 2011 What will do if i set debugscript 3 Link to comment
CowTurbo Posted June 17, 2011 Share Posted June 17, 2011 it will show ur script erros. Try, go in game, login with admin account, and write to chatbox /debugscript 3 Now you can see a small window down your screen, There will come errors, like to console ( black window, deffault ) but debugscript can show you errors what console cant. 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