Jump to content

Different gives money


Recommended Posts

Posted

Hello I need another code for my cruise system.

Example; If my vehicle's ID is 455, script gives me (5,15) money but,

if my vehicle's ID is 405 script gives me (20,50) how can I do that, please teach me or show me.

Posted

You have to use a table, if you wish to give different money on different vehicle IDs. If you have a calculation for it, you can just use that.

local moneyTable = {
	[405] = 2.15,
	[411] = 20.15
}

 

Posted

Thats the code you need to call the money from that table.

local pVehicle = getPedOccupiedVehicle(localPlayer)
local vehModel = getElementModel(pVehicle)
local pMoney = moneyTable[vehModel]
outputChatBox("That car is $" .. pMoney)

 

Posted

I already know NeXuS™, Why you speak?

[2017-07-22 23:37:06] WARNING: [gameplay]/moneydata/cruiseserver.lua:82: Bad argument @ 'getPedOccupiedVehicle' [Expected ped at argument 1, got nil]
[2017-07-22 23:37:06] WARNING: [gameplay]/moneydata/cruiseserver.lua:83: Bad argument @ 'getElementModel' [Expected element at argument 1, got boolean]
[2017-07-22 23:37:06] WARNING: [gameplay]/moneydata/cruiseserver.lua:90: Bad argument @ 'givePlayerMoney' [Expected number at argument 2, got nil]

I wrote to server.lua and geting that warning and I can't earn money from drive a car.

@NeXuS™ You got wrong me, I need the car gives money, not price

Posted
function kazan1 ()
local moneyTable = {
    [429] = math.random(5,200),
    [436] = math.random(5,25)
}
local thePlayer = getVehicleOccupant(source)
local pVehicle = getPedOccupiedVehicle(thePlayer)
local vehModel = getElementModel(pVehicle)
local pMoney = moneyTable[vehModel]

givePlayerMoney(thePlayer,pMoney)


end   
addEvent( "para5", true )
addEventHandler( "para5", root, kazan1 )

What is wrong?

Posted
function kazan1 ()
local moneyTable = {
    [429] = math.random(1,2),
    [436] = math.random(5,25)
}
local pVehicle = getPedOccupiedVehicle(source)
local vehModel = getElementModel(pVehicle)
local pMoney = moneyTable[vehModel]

       givePlayerMoney(source,pMoney)
end   
addEvent( "para5", true )
addEventHandler( "para5", getRootElement(), kazan1 )

That's working, ty for all my lifeguard. <3

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