Gabriele01 Posted July 21, 2017 Share Posted July 21, 2017 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. Link to comment
NeXuS™ Posted July 22, 2017 Share Posted July 22, 2017 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 } Link to comment
Gabriele01 Posted July 22, 2017 Author Share Posted July 22, 2017 I need to another code like for id, vehID in ipairs(moneyTable) do " xxxxxxxxx" end I need Xs at the here. Link to comment
NeXuS™ Posted July 22, 2017 Share Posted July 22, 2017 You can just get the money by calling the table with the index of the car's id. moneyTable[carID] Link to comment
Gabriele01 Posted July 22, 2017 Author Share Posted July 22, 2017 Type all code, not the part. Link to comment
NeXuS™ Posted July 22, 2017 Share Posted July 22, 2017 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) Link to comment
Gabriele01 Posted July 22, 2017 Author Share Posted July 22, 2017 I'll try it with table. Link to comment
Gordon_G Posted July 22, 2017 Share Posted July 22, 2017 It's an helping forum, so don't ask for a script right here. Link to comment
Gabriele01 Posted July 22, 2017 Author Share Posted July 22, 2017 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 Link to comment
NeXuS™ Posted July 22, 2017 Share Posted July 22, 2017 Its a server sided script, it would work totally fine, you should replace the 'localPlayer' in the getPedOccupiedVehicle with the player element on the server sided script. Link to comment
Gabriele01 Posted July 22, 2017 Author Share Posted July 22, 2017 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? Link to comment
NeXuS™ Posted July 22, 2017 Share Posted July 22, 2017 Is 'source' a vehicle element? Link to comment
Gabriele01 Posted July 22, 2017 Author Share Posted July 22, 2017 I don't know what is what, I'm so confused. Link to comment
Gabriele01 Posted July 22, 2017 Author Share Posted July 22, 2017 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 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