szlend Posted February 16, 2008 Share Posted February 16, 2008 (edited) You can only give money to players. Maybe there's another element in that sphere. Try this: function Money( hitElement, matchingDimension) if ( getElementType ( hitElement ) == "player" ) then timer = setTimer( givePlayerMoney, 1000, 0, hitElement, 10 ) end end Edited February 16, 2008 by Guest Link to comment
Mr.Hankey Posted February 16, 2008 Share Posted February 16, 2008 hm... i think it's just an incorrect function you defined in the timer. Try this: function Place(name) if name ~= getThisResource() then return else local marker = createMarker ( -1025.5623779297, 457.65173339844, 14, "cylinder", 4, 0, 100, 200, 250 ) end end function Money( hitElement, matchingDimension) timer = setTimer( givePlayerMoney, 1000, 0, hitElement, 10 )-- there's no function called giveMoney you should better try givePlayerMoney end function money_stop () killTimer (timer) end Col = createColSphere ( -1025.5623779297, 457.65173339844, 14, 4 ) addEventHandler ( "onColShapeHit", Col, Money ) addEventHandler ( "onColShapeLeave", Col, money_stop) addEventHandler ( "onResourceStart", getRootElement(), Place) Link to comment
50p Posted February 16, 2008 Share Posted February 16, 2008 hitElement is the marker that you hit/enter... use source. You can't give money to marker http://development.mtasa.com/index.php? ... rMarkerHit You can call "native" functions using timer. giveMoney's native, like all of the functions you can find on wiki. So there is no need of creating new function which calls 1 different function. It's not like PAWN where you must do it that way. Link to comment
XetaQuake Posted February 16, 2008 Author Share Posted February 16, 2008 thanks for help @ all! now i am using the snippets from szlend, and it works great! But thanks for all again! Link to comment
Mr.Hankey Posted February 16, 2008 Share Posted February 16, 2008 well i couldn't find a function that is called giveMoney http://development.mtasa.com/index.php?search=giveMoney&fulltext=Search and i always used this and it works fine http://development.mtasa.com/index.php?title=GivePlayerMoney hm... and for the marker you're right the hitElement is the marker i have never checked it but someone here in this thread said that hitElement is the player^^ Link to comment
szlend Posted February 16, 2008 Share Posted February 16, 2008 well i couldn't find a function that is called giveMoney http://development.mtasa.com/index.php?search=giveMoney&fulltext=Searchand i always used this and it works fine http://development.mtasa.com/index.php?title=GivePlayerMoney hm... and for the marker you're right the hitElement is the marker i have never checked it but someone here in this thread said that hitElement is the player^^ That's because he's using onColShapeHit event not OnPlayerMarkerHit Link to comment
Mr.Hankey Posted February 16, 2008 Share Posted February 16, 2008 ahhhh now it does all make sense thx szlend Link to comment
XetaQuake Posted February 16, 2008 Author Share Posted February 16, 2008 hi again i have found a bug ;/ when two players are in the marker the player get every time money! not only when there are in the marker here my currently code i use: function Place(name) if name ~= getThisResource() then return else local marker = createMarker ( -1025.5623779297, 457.65173339844, 14, "cylinder", 4, 0, 100, 200, 250 ) end end function Money( hitElement, matchingDimension) if ( getElementType ( hitElement ) == "player" ) then timer = setTimer( givePlayerMoney, 1000, 0, hitElement, 10 ) end end function money_stop () killTimer (timer) end Col = createColSphere ( -1025.5623779297, 457.65173339844, 14, 4 ) addEventHandler ( "onColShapeHit", Col, Money ) addEventHandler ( "onColShapeLeave", Col, money_stop) addEventHandler ( "onResourceStart", getRootElement(), Place) have anybody a idea to fix this? i think the problem is anywhere on killTimer Link to comment
50p Posted February 16, 2008 Share Posted February 16, 2008 well i couldn't find a function that is called giveMoney http://development.mtasa.com/index.php?search=giveMoney&fulltext=Search My bad. Link to comment
szlend Posted February 16, 2008 Share Posted February 16, 2008 the killTimer just kills the "timer" for the last player. I think the easiest way to work around this is to make the script client side. Link to comment
XetaQuake Posted February 16, 2008 Author Share Posted February 16, 2008 hmm, it is not possibly to make this server side too? because i dont know to make ALL client side... Link to comment
50p Posted February 17, 2008 Share Posted February 17, 2008 You can create a table which will store each players' timer and then kill them when it's required. What you did was just create a timer when someone enters marker, the timer is killed, but the timer is only for one player and can be killed when you don't really want to. So, try a global table and store each player's timer in that table. eg: local timers = { } -- somewhere at the top of script ... -- replace old: timer = setTimer... with this: timers[ source ] = setTimer(blah, ...) ... -- and so killTimer killTimer( timers[ source ] ) Link to comment
XetaQuake Posted February 17, 2008 Author Share Posted February 17, 2008 good idea but this dont work so good, because: when only 1 player go in the marker all working good, and when i go out of the marker, i get no money - perfect but: when 2 players in the marker, i dont only get money when the first player that joined the server are in the marker, and when the player go out of the marker, i get no money too it is realy not easy to explain the problem...i hope somebody know a fix all realy strange Link to comment
Guest Posted February 17, 2008 Share Posted February 17, 2008 Me and my freind are going to make drifting movie in san andreas, and we was thinking to take away the crosshair on the camera and use fraps to record. but we dont have a lan mode for that, and we was wondering if some one could make that for us? a mode so we can have camera as weapon, our own handling, and mayby if possible a car spawner that can spawn any cars. can some one make that for us? i dont think it gonna take a long time, becouse we dont need that spawns in the street and no missions or somthing like that.. Sry for bad english! im from norway. Thanx for help Link to comment
XetaQuake Posted February 17, 2008 Author Share Posted February 17, 2008 yeh! ^^ this is my thread and here is my currently full code, so PLEAS peaple test it on own server with 2 players in the marker, than you can see the problem. i dont know how to exlain this problem (or to fix it) local timers = { } function Place(name) if name ~= getThisResource() then return else local marker = createMarker ( -1025.5623779297, 457.65173339844, 14, "cylinder", 4, 0, 100, 200, 250 ) end end function Money( hitElement, matchingDimension) if ( getElementType ( hitElement ) == "player" ) then timers[ source ] = setTimer( givePlayerMoney, 1000, 0, hitElement, 10 ) end end function money_stop () killTimer( timers[ source ] ) end Col = createColSphere ( -1025.5623779297, 457.65173339844, 14, ) addEventHandler ( "onColShapeHit", Col, Money ) addEventHandler ( "onColShapeLeave", Col, money_stop) addEventHandler ( "onResourceStart", getRootElement(), Place) the marker are on the airport, second city on the end of the starting area Link to comment
szlend Posted February 17, 2008 Share Posted February 17, 2008 Read: http://development.mtasa.com/index.php? ... ShapeLeave function money_stop () killTimer( timers[ source ] ) end You are killing the timer for ColShape not the player which is wrong. It should look like this: function money_stop (leaveElement, matchingDimension) if ( getElementType ( leaveElement ) == "player" ) then -- not really needed. just to prevent killing non-existing timers killTimer( timers[ leaveElement ] ) end end Link to comment
50p Posted February 17, 2008 Share Posted February 17, 2008 I said: hitElement is the marker that you hit/enter... use source.You can't give money to marker http://development.mtasa.com/index.php? ... rMarkerHit If you create a marker, why do you create col shape if there is an event for markers already? You can use the code that szlend gives. Link to comment
XetaQuake Posted February 17, 2008 Author Share Posted February 17, 2008 ahhh okay thanks OnColshapeLeave is good! i get a warning when i leave the marker and the money dont stop, the problem are on line 17: killTimer( timers[ leaveElement ] ) i have already try to change the line a bit with some possibles, but that don't have solved the bug a last help? Link to comment
50p Posted February 17, 2008 Share Posted February 17, 2008 You get a warning message, but what's that message? Link to comment
XetaQuake Posted February 17, 2008 Author Share Posted February 17, 2008 oops sorry Bad argument @ 'killTimer' - Line: 17 Link to comment
szlend Posted February 17, 2008 Share Posted February 17, 2008 Also noticed this: function Money( hitElement, matchingDimension) if ( getElementType ( hitElement ) == "player" ) then timers[ source ] = setTimer( givePlayerMoney, 1000, 0, hitElement, 10 ) end end Should be: function Money( hitElement, matchingDimension) if ( getElementType ( hitElement ) == "player" ) then timers[ hitElement ] = setTimer( givePlayerMoney, 1000, 0, hitElement, 10 ) end end And read what 50p said. Why use a ColShape at all? Link to comment
Guest Posted February 18, 2008 Share Posted February 18, 2008 Me and my freind are going to make drifting movie in san andreas, and we was thinking to take away the crosshair on the camera and use fraps to record. but we dont have a lan mode for that, and we was wondering if some one could make that for us? a mode so we can have camera as weapon, our own handling, and mayby if possible a car spawner that can spawn any cars. can some one make that for us? i dont think it gonna take a long time, becouse we dont need that spawns in the street and no missions or somthing like that.. Sry for bad english! im from norway. Thanx for help Link to comment
XetaQuake Posted February 18, 2008 Author Share Posted February 18, 2008 Also noticed this: function Money( hitElement, matchingDimension) if ( getElementType ( hitElement ) == "player" ) then timers[ source ] = setTimer( givePlayerMoney, 1000, 0, hitElement, 10 ) end end Should be: function Money( hitElement, matchingDimension) if ( getElementType ( hitElement ) == "player" ) then timers[ hitElement ] = setTimer( givePlayerMoney, 1000, 0, hitElement, 10 ) end end And read what 50p said. Why use a ColShape at all? thanks szlend! thats works i am wondered that the problem was not the killtimmer, but now i have learning and yes you are right its better i read a little bit more on the wiki and to answer your question: the marker and colshape are from a marker+teleport script thanks for all thread finish (for me ^) 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