Jump to content

Vehicle Sloths


Cyan

Recommended Posts

I think the easyest way for doing that is seting accountData.

When player boughts car, then set he's account data to that vehicle what he did bought. So, if you wanna do that with different buttons..

  
-- For buying car 
function buyCar1 ( carName,price ) 
    local playerAccount = getPlayerAccount ( source ) 
        local car1 = getAccountData ( playerAccount, "Car1" )  
        if not( car1 ) then 
            if ( getPlayerMoney => price ) then 
                setAccountData ( playerAccount, "Car1", carName )  -- For model, you can do getVehicleModelFromName function,  
                setAccountData ( playerAccount, "Car1Price", price ) -- We can give him money back when he sell easyly 
                takePlayerMoney ( source, price ) 
                outputChatBox ( "Gratz! You have boughted "..carName.."! Price: "..price, source, 255, 0, 255 ) 
            else 
                outputChatBox ( "* ERROR: You dont have so much money! Needed: "..price.."!", source, 255,0,0 ) 
            end 
        else 
            triggerClientEvent ( source, "showErrorOnCar1Buy", source )  --  > This will show you error, something like "Are you sure you wanan buy that car? You already have a car on that slot" ... 
        end 
end 
addEvent ( "buyCar1", true ) 
addEventHandler ( "buyCar1", getRootElement(), buyCar1 ) 
  
-- For selling car 
  
function sellCar1 ( ) 
    local playerAccount = getPlayerAccount ( source ) 
        local car1 = getAccountData ( playerAccount, "Car1" )  
        if ( car1 ) then 
            setAccountData ( playerAccount, "Car1", nil )   
            local price = getAccountData ( playerAccount, "Car1Price" ) 
            outputChatBox ( "Gratz! You have sold "..car1.."! Obtained: "..price/2, source, 255, 0, 255 )  
            givePlayerMoney ( source, price/2 ) 
        else 
            triggerClientEvent ( source, "showErrorOnCar1Sell", source )  --  > This will show you error, when you sell car, like "Are you sure ?" .. 
        end 
end 
addEvent ( "sellCar1", true ) 
addEventHandler ( "sellCar1", getRootElement(), sellCar1 ) 
  

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