NotAvailable Posted July 3, 2010 Share Posted July 3, 2010 (edited) -------------------------- Edited December 19, 2011 by Guest Link to comment
MaddDogg Posted July 3, 2010 Share Posted July 3, 2010 https://wiki.multitheftauto.com/wiki/Main_Page https://wiki.multitheftauto.com/wiki/OnClientMarkerHit https://wiki.multitheftauto.com/wiki/SetElementHealth https://wiki.multitheftauto.com/wiki/TakePlayerMoney That should be everything, you'll need. Link to comment
TheRealCow Posted July 3, 2010 Share Posted July 3, 2010 function onStart () marker = createMarker ( 0, 0, 0, "cylinder", 2.5, 0, 0, 255, 150 ) end addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()) function entering ( source ) local money = getPlayerMoney( source ) if ( money >= 100 ) then setElementHealth ( source, 100 ) outputChatBox ( "Healthed", source, 0, 255, 0 ) else outputChatBox ( "You dont have enoguht money! ( 100$ )", source, 255, 0, 0 ) end end addEventHandler ( "onMarkerHit", marker, entering ) no tested.. Link to comment
m4rsje Posted July 3, 2010 Share Posted July 3, 2010 yeah but you do need to make an option too, when your health is 100% he will still lose his cash right? you should make an another option like: a = getElementHealth (source) if a == <100 then or something like that still nice done Link to comment
dzek (varez) Posted July 3, 2010 Share Posted July 3, 2010 https://wiki.multitheftauto.com/wiki/OnClientMarkerHit better use https://wiki.multitheftauto.com/wiki/OnMarkerHit no need for checking this client-side just to trigger server event, he needs to take money/set hp anyway Link to comment
50p Posted July 3, 2010 Share Posted July 3, 2010 Your code will not work TheRealCow... For couple of reasons: - addEventHandler ( "onMarkerHit", marker, entering ) will be executed before the actual marker is created. - DO NOT ever add source as function parameter.. You will get into issues that you wouldn't want if that function gets longer and other features are added to the function. This is not actually a reason why it won't work but an advice for you. Also, if you expect player to be the element that hit the marker, make sure the element is player because getPlayerMoney will give warning if the element that hit the marker is vehicle (or player is inside vehicle). This should still work but if you release your resource always make sure it doesn't output any error/warning message because it's annoying if someone debugs his script and sees warning/error messages coming up from different resource. And as m4sje said, you need to add an if statement to check if player's health is not full because you don't want to be charged $100 for nothing. Link to comment
NotAvailable Posted July 4, 2010 Author Share Posted July 4, 2010 (edited) ------------------------------ Edited December 19, 2011 by Guest Link to comment
NotAvailable Posted July 7, 2010 Author Share Posted July 7, 2010 (edited) ------------------------------ Edited December 19, 2011 by Guest Link to comment
50p Posted July 7, 2010 Share Posted July 7, 2010 Sort of. You don't check and take player money. You don't need triggerServerEvent... what is it for? I suggest you look into other scripts or get to know MTA scripting more by reading wiki. Link to comment
m4rsje Posted July 8, 2010 Share Posted July 8, 2010 So.. Something like this? function ghealth( thePlayer ) local health = getPlayerHealth(thePlayer) if (health > 1) then setPlayerHealth ( 100 ) triggerServerEvent ( "givehealth", getLocalPlayer(), "24","10" ) else outputChatBox("* You dont have enough money!", thePlayer ) end end you can try this: local root = getRootElement() addEventHandler("onPickupUse", root, function( thePlayer ) local health = getPlayerHealth(thePlayer) if (health > 1) then local money = getPlayerMoney(thePlayer) if (money > 100) then takePlayerMoney(thePlayer, 100) setPlayerHealth ( 100 ) else outputChatBox("* You dont have enough money!", thePlayer ) end end end ) Link to comment
NotAvailable Posted July 8, 2010 Author Share Posted July 8, 2010 (edited) ------------------------------ Edited December 19, 2011 by Guest Link to comment
m4rsje Posted July 8, 2010 Share Posted July 8, 2010 i didn't test it so tell me if you get a bug btw you have to make the pickup first Link to comment
NotAvailable Posted July 8, 2010 Author Share Posted July 8, 2010 (edited) ------------------------------ Edited December 19, 2011 by Guest Link to comment
m4rsje Posted July 8, 2010 Share Posted July 8, 2010 Aaahh I think you should add this to it: if (source == name-from-pickup) then Add that after the function (thePlayer) And add a new "end";) Bec he cant know where he have to add the function bec you didn't gave a pickup where it happens Link to comment
NotAvailable Posted July 8, 2010 Author Share Posted July 8, 2010 (edited) -------------------------- Edited December 19, 2011 by Guest Link to comment
m4rsje Posted July 8, 2010 Share Posted July 8, 2010 haha well it was abit my fault i forgot it too ^^ Link to comment
NotAvailable Posted July 8, 2010 Author Share Posted July 8, 2010 (edited) -------------------------- Edited December 19, 2011 by Guest Link to comment
m4rsje Posted July 8, 2010 Share Posted July 8, 2010 Its an regular script Just add this to your meta.xml: Link to comment
NotAvailable Posted July 8, 2010 Author Share Posted July 8, 2010 (edited) -------------------------- Edited December 19, 2011 by Guest Link to comment
NotAvailable Posted July 8, 2010 Author Share Posted July 8, 2010 (edited) -------------------------- Edited December 19, 2011 by Guest Link to comment
NotAvailable Posted July 8, 2010 Author Share Posted July 8, 2010 (edited) -------------------------- Edited December 19, 2011 by Guest Link to comment
dzek (varez) Posted July 8, 2010 Share Posted July 8, 2010 if (health > 1) then you really need this? edit: almost dying players wont get healthed.. Link to comment
NotAvailable Posted July 8, 2010 Author Share Posted July 8, 2010 (edited) -------------------------- Edited December 19, 2011 by Guest 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