Jump to content

Need a bit of help.


Recommended Posts

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
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
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
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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...