TheScriptingNewbie Posted February 21, 2013 Share Posted February 21, 2013 Hello, i have a script when a player drives through a cluck 'n bell drivethru and gets food, but when player has no money he still gets the food, only the money goes to the negative, what can i do when the player doesn't have any money, it wouldn't give him food and take no money? Script: local marker = createMarker( 2377.60, -1909.09, 13.39, "cylinder", 3, 255, 0, 0, 100 ) addEventHandler("onMarkerHit", marker, function(hitElement) if (getElementType(hitElement) == "player") then setElementHealth(hitElement, 200 ) takePlayerMoney(hitElement, 1) outputChatBox( "you bought chicken", hitElement, 0, 255, 0 ) end end ) function setBlip1( ) local blip1 = createBlip( 2377.60, -1909.09, 13.39, 14, root ) setBlipVisibleDistance( blip1, 10000 ) end addEventHandler( "onResourceStart", root, setBlip1 ) Sorry for my english. Link to comment
Sparrow Posted February 21, 2013 Share Posted February 21, 2013 local marker = createMarker( 2377.60, -1909.09, 13.39, "cylinder", 3, 255, 0, 0, 100 ) addEventHandler("onMarkerHit", marker, function(hitElement) if (getElementType(hitElement) == "player") then if (getPlayerMoney(hitElement) >= 1) then setElementHealth(hitElement, 200 ) takePlayerMoney(hitElement, 1) outputChatBox( "you bought chicken", hitElement, 0, 255, 0 ) else outputChatBox("You haven't enough money!", hitElement, 255, 0, 0) end end end ) function setBlip1( ) local blip1 = createBlip( 2377.60, -1909.09, 13.39, 14, root ) setBlipVisibleDistance( blip1, 10000 ) end addEventHandler( "onResourceStart", root, setBlip1 ) Link to comment
Metall Posted February 21, 2013 Share Posted February 21, 2013 if (getPlayerMoney(hitElement) >= 100) then Well, that checks if the player got less than 100$, you could change the "100" to whatever amount you wan't. And to place this in ur script, place it like this: addEventHandler("onMarkerHit", marker, function(hitElement) if (getElementType(hitElement) == "player") then if (getPlayerMoney(hitElement) >= 100) then setElementHealth(hitElement, 200 ) takePlayerMoney(hitElement, 1) outputChatBox( "you bought chicken", hitElement, 0, 255, 0 ) end end ) Under the 3rd line, so to say... Link to comment
Castillo Posted February 21, 2013 Share Posted February 21, 2013 That checks if the player has $100 or more. Link to comment
TheScriptingNewbie Posted February 21, 2013 Author Share Posted February 21, 2013 That checks if the player has $100 or more. Thank you all, it works, i have another question, is there a way to repair a vehicle when you drive with it into a marker? Using the same money system like now? Link to comment
iPrestege Posted February 21, 2013 Share Posted February 21, 2013 fixVehicle isPedInVehicle Link to comment
Castillo Posted February 21, 2013 Share Posted February 21, 2013 Yes, it is. Use the following things: Functions: createMarker getElementType isPedInVehicle fixVehicle Event: onMarkerHit Link to comment
iPrestege Posted February 21, 2013 Share Posted February 21, 2013 Yes, it is.Use the following things: Functions: createMarker getElementType isPedInVehicle fixVehicle Event: onMarkerHit You forgot this: getPlayerMoney Link to comment
TheScriptingNewbie Posted February 21, 2013 Author Share Posted February 21, 2013 Yes, it is.Use the following things: Functions: createMarker getElementType isPedInVehicle fixVehicle Event: onMarkerHit Thank you, will be a very good practice for me, since i am a beginner!! I am also very thankfull for this community, and i am planning a little thing when this small gamemode is done, hope you will like it.Ofcourse, don't expect too much, it will be very simple Link to comment
Castillo Posted February 21, 2013 Share Posted February 21, 2013 Yes, it is.Use the following things: Functions: createMarker getElementType isPedInVehicle fixVehicle Event: onMarkerHit You forgot this: getPlayerMoney He's already using it on his previous script, so he already knows that he must use it. 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