greenday Posted May 29, 2014 Share Posted May 29, 2014 Hi, Im trying to make a script in which - when a client hits a marker, $500 will be deducted from his money. The code I wrote is not working and I need help: marker_00 = createMarker(1178,-1317,14,"cylinder",1,255,255,150) marker_01 = createMarker(1252,329,20,"cylinder",1,255,255,150) marker_02 = createMarker(-312,1052,20.5,"cylinder",1,255,255,150) marker_03 = createMarker(1600,1820,11,"cylinder",1,255,255,150) marker_04 = createMarker(-2667,636,14.5,"cylinder",1,255,255,150) marker_05 = createMarker(2030,-1405,17.5,"cylinder",1,255,255,150) marker_06 = createMarker(-1520,2520,56,"cylinder",1,255,255,150) marker_07 = createMarker(-2190,-2300,30.5,"cylinder",1,255,255,150) marker_08 = createMarker(2026,-1408,16,"cylinder",1,255,255,150) function takeHisMoney(thePlayer) takePlayerMoney (thePlayer, 500) end addEventHandler("onClientMarkerHit", marker_00,takeHisMoney) addEventHandler("onClientMarkerHit", marker_01,takeHisMoney) addEventHandler("onClientMarkerHit", marker_02,takeHisMoney) addEventHandler("onClientMarkerHit", marker_03,takeHisMoney) addEventHandler("onClientMarkerHit", marker_04,takeHisMoney) addEventHandler("onClientMarkerHit", marker_05,takeHisMoney) addEventHandler("onClientMarkerHit", marker_06,takeHisMoney) addEventHandler("onClientMarkerHit", marker_07,takeHisMoney) addEventHandler("onClientMarkerHit", marker_08,takeHisMoney) Link to comment
manawydan Posted May 29, 2014 Share Posted May 29, 2014 try: client marker_00 = createMarker(1178,-1317,14,"cylinder",1,255,255,150) marker_01 = createMarker(1252,329,20,"cylinder",1,255,255,150) marker_02 = createMarker(-312,1052,20.5,"cylinder",1,255,255,150) marker_03 = createMarker(1600,1820,11,"cylinder",1,255,255,150) marker_04 = createMarker(-2667,636,14.5,"cylinder",1,255,255,150) marker_05 = createMarker(2030,-1405,17.5,"cylinder",1,255,255,150) marker_06 = createMarker(-1520,2520,56,"cylinder",1,255,255,150) marker_07 = createMarker(-2190,-2300,30.5,"cylinder",1,255,255,150) marker_08 = createMarker(2026,-1408,16,"cylinder",1,255,255,150) function takeHisMoney(thePlayer) triggerServerEvent("ReduceMoneyTrigger",thePlayer) end addEventHandler("onClientMarkerHit", marker_00,takeHisMoney) addEventHandler("onClientMarkerHit", marker_01,takeHisMoney) addEventHandler("onClientMarkerHit", marker_02,takeHisMoney) addEventHandler("onClientMarkerHit", marker_03,takeHisMoney) addEventHandler("onClientMarkerHit", marker_04,takeHisMoney) addEventHandler("onClientMarkerHit", marker_05,takeHisMoney) addEventHandler("onClientMarkerHit", marker_06,takeHisMoney) addEventHandler("onClientMarkerHit", marker_07,takeHisMoney) addEventHandler("onClientMarkerHit", marker_08,takeHisMoney) server addEvent("ReduceMoneyTrigger",true) addEventHandler("ReduceMoneyTrigger",root, function() local money = getPlayerMoney(client) if(money>=500)then takePlayerMoney(client,500) else outputChatBox("No enought money",client) end end) Link to comment
manawydan Posted May 29, 2014 Share Posted May 29, 2014 but here is better(i think) client marker_00 = createMarker(1178,-1317,14,"cylinder",1,255,255,150) marker_01 = createMarker(1252,329,20,"cylinder",1,255,255,150) marker_02 = createMarker(-312,1052,20.5,"cylinder",1,255,255,150) marker_03 = createMarker(1600,1820,11,"cylinder",1,255,255,150) marker_04 = createMarker(-2667,636,14.5,"cylinder",1,255,255,150) marker_05 = createMarker(2030,-1405,17.5,"cylinder",1,255,255,150) marker_06 = createMarker(-1520,2520,56,"cylinder",1,255,255,150) marker_07 = createMarker(-2190,-2300,30.5,"cylinder",1,255,255,150) marker_08 = createMarker(2026,-1408,16,"cylinder",1,255,255,150) function takeHisMoney(thePlayer) if(source==marker_00) or(source==marker_01)or (source==marker_02)or(source==marker_03)or(source==marker_04) or(source==marker_05) or (source==marker_06) or (source==marker_07)or(source==marker_08) then triggerServerEvent("ReduceMoneyTrigger",thePlayer) end end addEventHandler("onClientMarkerHit", root,takeHisMoney) Link to comment
greenday Posted May 29, 2014 Author Share Posted May 29, 2014 Thanks a ton bro! the script works perfectly! Just 1 more thing, I need to set the player's health to 200 when he hit the marker also. Please tell me how I implement setElementHealth to the script you suggested up. Link to comment
manawydan Posted May 29, 2014 Share Posted May 29, 2014 addEvent("ReduceMoneyTrigger",true) addEventHandler("ReduceMoneyTrigger",root, function() local money = getPlayerMoney(client) if(money>=500)then takePlayerMoney(client,500) setPedStat(client,24,999) setElementHealth(client,200) else outputChatBox("No enought money",client) end end) Link to comment
greenday Posted May 29, 2014 Author Share Posted May 29, 2014 Whoa, that was simple and effective. Hope I become an experienced scripter like you one day Thanks again Link to comment
#DRAGON!FIRE Posted May 29, 2014 Share Posted May 29, 2014 takePlayerMoney on client -__- On Client is Phantom Link to comment
xXMADEXx Posted May 29, 2014 Share Posted May 29, 2014 I think that you should actually use this for the function/event handler: function takeHisMoney(thePlayer) if ( thePlayer == localPlayre ) then triggerServerEvent("ReduceMoneyTrigger",thePlayer) end end addEventHandler("onClientMarkerHit", marker_00, takeHisMoney) addEventHandler("onClientMarkerHit", marker_01, takeHisMoney) addEventHandler("onClientMarkerHit", marker_02, takeHisMoney) addEventHandler("onClientMarkerHit", marker_03, takeHisMoney) addEventHandler("onClientMarkerHit", marker_04, takeHisMoney) addEventHandler("onClientMarkerHit", marker_05, takeHisMoney) addEventHandler("onClientMarkerHit", marker_06, takeHisMoney) addEventHandler("onClientMarkerHit", marker_07, takeHisMoney) addEventHandler("onClientMarkerHit", marker_08, takeHisMoney) You forgot to check if the player is the localPlayer. Link to comment
Karuzo Posted May 29, 2014 Share Posted May 29, 2014 You made a small typo xXMADEXx. line 2 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