Jump to content

Search the Community

Showing results for tags 'for-loop'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Multi Theft Auto: San Andreas 1.x
    • Support for MTA:SA 1.x
    • User Guides
    • Open Source Contributors
    • Suggestions
    • Ban appeals
  • General MTA
    • News
    • Media
    • Site/Forum/Discord/Mantis/Wiki related
    • MTA Chat
    • Other languages
  • MTA Community
    • Scripting
    • Maps
    • Resources
    • Other Creations & GTA modding
    • Competitive gameplay
    • Servers
  • Other
    • General
    • Multi Theft Auto 0.5r2
    • Third party GTA mods
  • Archive
    • Archived Items
    • Trash

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Gang


Location


Occupation


Interests

Found 1 result

  1. So I am making a vehicle shop system. I want some vehicles to have changed handling when they spawn. There's a problem, 'cause a 'for loop' that sets handlings isn't executed. I don't know what could cause this. Here's the code: local vehSale = {} vehSale["premier"] = {426, 2000, {}} vehSale["blista-compact"] = {496, 2400, {}} hdl_blista_compact_rwd = {} hdl_blista_compact_rwd["driveType"] = "rwd" hdl_blista_compact_rwd["mass"] = 1040 vehSale["blista-compact-rwd"] = {496, 2800, hdl_blista_compact_rwd} hdl_blista_sport = {} hdl_blista_sport["driveType"] = "rwd" hdl_blista_sport["mass"] = 1100 hdl_blista_sport["engineAcceleration"] = 12.8 hdl_blista_sport["engineInertia"] = 4 hdl_blista_sport["collisionDamageMultiplier"] = 0.55 hdl_blista_sport["steeringLock"] = 35 vehSale["blista-sport"] = {496, 4500, hdl_blista_sport} function buyVehicle(source, cmdName, vName) if not vehSale[vName] then outputChatBox("There is no such vehicle for sale", source) return false end if getPlayerMoney(source) < vehSale[vName][2] then outputChatBox("You don't have money for that", source) return false end local veh = createVehicle(vehSale[vName][1], 0, 0, 0) spawnVehicle(veh, -1706, 13, 5) for k, v in ipairs(vehSale[vName][3]) do print(k) setVehicleHandling(veh, k, v) end setPlayerMoney(source, getPlayerMoney(source)-vehSale[vName][2]) outputChatBox("Vehicle bought", source) end addCommandHandler("buy", buyVehicle) So I made a table (vehSale) where I put all avaliable cars. Under key premier at 1st index is vehicle ID, 2nd - price, 3rd - Handlings to change. I wrote a function that lets players buy vehicles. It's named buyVehicle(). First it checks if vehicle is avaliable and if player can afford it. Next it spawns vehicle at San Fierro docks and then applies handling. And that part of code doesn't work. After loop subtracts player money and outputs "Vehicle bought". Anything but that loop does work. I tried this code at the beggining of program: for k, v in ipairs(getOriginalHanling(496)) do print(k) print(v) end And this doesn't work too. Man, f*ck this. I've just changed ipairs() to pairs() and ANYTHING is WORKING. Lol
×
×
  • Create New...