Jump to content

DriFtyZ

Members
  • Posts

    73
  • Joined

  • Last visited

Everything posted by DriFtyZ

  1. Nevermind, i fixed the issue just by reconnecting to the game.
  2. thanks for the answer i realized the variables in pairs get replaced every time so i just named them dff and txd also my second fault was for using ipairs when i wanted both indexes of the table so changing ipairs to pairs worked and now the script is working good.
  3. Hello community, i've made a simple loader script to replace the stock gas station in Los Santos, the assets seem to load and i see that mta tries to load the model but it doesn't in the end. Stock Gas Station Remains. Also no errors or anything in debugscript 3. here's my code i can't find the mistake here. Thanks local Models = { laepetrol1a = 5409, washgaspump = 1676, } local Textures = { barrio1_lae = 5409, wshxrefpump = 1676, } local COLS = { lae_4 = 1676, } local SHELL_PATH = "assets/Shell/" addEventHandler("onClientResourceStart", resourceRoot, function() -- Load Textures First for name, id in pairs(Textures) do local txd = engineLoadTXD ( SHELL_PATH .. name .. ".txd" ) engineImportTXD ( txd, id ) outputDebugString("GasStation: Loaded TXD (" .. SHELL_PATH .. name .. ".txd) | ID: " .. id) end for name, id in pairs(Models) do local dff = engineLoadDFF ( SHELL_PATH .. name .. ".dff" ) engineReplaceModel ( dff, id ) outputDebugString("GasStation: Loaded DFF (" .. SHELL_PATH .. name .. ".dff) | ID: " .. id) end for name, id in pairs(COLS) do local col = engineLoadCOL ( SHELL_PATH .. name .. ".col" ) --engineReplaceCOL ( col, id ) outputDebugString("GasStation: Loaded COL (" .. SHELL_PATH .. name .. ".col) | ID: " .. id) end end)
  4. Hello, i am trying to create a vehicle loader script that loads all the vehicle models from a Lua table instead of adding them manually one by one but i am getting "error unexpected symbol near .." Now i know my syntax is wrong in line 18 and 20 where i try to create a variable based from the name index on the Lua table but i don't know how to accomplish it. Any help would be appreciated. Thanks local vehiclesFileNames = { AE86 = 589, ToyotaSupra = 559, ToyotaAltezza = 402, Datsun240Z = 475, Nissan180SX = 602, SilviaS13 = 401, SilviaS14 = 576, SilviaS15 = 474, Skyline2000 = 535, SkylineR32 = 555, SkylineR34 = 562, SkylineGTR = 558, } function loadVehicleFiles() for name, id in ipairs(vehiclesFileNames) do local name..txd = engineLoadTXD ( "Cars/"..name.."/"..name..".txd") engineImportTXD ( name..txd, id ) local name..dff = engineLoadDFF ( "Cars/"..name.."/"..name..".dff") engineReplaceModel ( name..dff, id ) outputDebugString("name = "..name.." | id = "..id..".") end end addEventHandler("onClientResourceStart", resourceRoot, loadVehicleFiles())
  5. Fair enough you answered almost all my questions, but there is one more. if you player:setHealth(50) that "player" needs to be defined right? So if the player is defined somehow either from source or from a variable like local driftyz = getLocalPlayer() can i use driftyz:setHealth(50)? Thanks in advance
  6. okay makes sense it is faster to write, but for people like me who don't know the OOP functions will have to learn them, because i remember it took me months to learn most of the procedural mta functions. Guess it is more advanced even tho it sounds more simple
  7. Hello MTA SA Community i started this thread so someone who knows how the OOP works can explain it to me aswell because i have some questions and couldn't understand some of the wiki. I've seen some people using OOP in their resources instead of calling exported functions if i saw correctly. Can i use OOP to replace some exported functions? for example if i have to call a notification resource to show notifications can i use OOP to call that function who will post notifications on the player screen? And second what is the main point to use OOP at all?
  8. The brackets wasn't a problem i tried it without them before, anyways ill try the "call" way and let you know
  9. <exports function="showErrorCode" type="server" /> It might looks messed because im from my phone
  10. Exact what the title says, i can't figure it out what is wrong with a simple exports code im testing, thanks! error: Failed to call '[DWN]Core:showErrorCode'[string "?"] code to call the function: exports["[DWN]Core"]:showErrorCode(player, "02") code of the exported function: function showErrorCode (player, int) if player then if int == "02" then -- Some random code to excecute here outputChatBox("It Works!") end end end
  11. Correct but as i said i haven't explained what i wanted correctly which i fixed it later and that link wasn't what i was looking for.
  12. I'm sorry my mistake i should have put [QUESTION] tag and i didn't explained well what i wanted tough i fixed it, this guy also didn't behave gentle instead of he threw a common link onto my face telling me to quit calling stuff like this bugs like i'm doing it every day
  13. Quit being an smartass
  14. Yes, Its an another one annoying question from me, i have a vehicle menu where the player selects which vehicle he wants to spawn/hide unlock etc... the menu finds the player's owned vehicles through a dbQuery and separates them into rows inside the gridlist when i select a vehicle it spawns it based on the plate text, but when i close and open the menu again it just's deselects the selected row... In few words i want to make the gui selects the row itself if the vehicle is spawned when the player opens the menu how can this be possible, thanks! EDIT: Pic is a bit aged don't mind if the other buttons i said are not included in
  15. thank you, i was so dumb that just tried to use only a useful function without copying the code below
  16. Hello people, i noticed on the wiki there are some function called Useful functions, how can i use them? what are they exactly?
  17. Hello there, i want to export some database functions instead of using db connect on all resources, how can i make it?
  18. crashes can always happen for whatever reason, anyway
  19. agreed, but if server is running for long time and a crash happens then the database would be looong behind i think
  20. i was thinking something about leaving the vehicle or despawing but i was to focused on how to make the health show correct first and then i forgot it, thank you for reminding me this
  21. vehHealth 2 on iprint is correct, wait imma modify this into a client side function i did before works like a charm right now, in speedometer it always show current health because its getting refreshed in every HUD rendered frame but in script it just stayed 1 health variable behind and seems the 50ms delay gets it fixed -- Sync vehicle damage from client to server local damageTimeCount = 0 addEventHandler("onClientVehicleDamage", getRootElement(), function(attacker, weapon, loss, x, y, z, tyre) damageTimeCount = damageTimeCount + 1 if attacker or weapon then cancelEvent() end local vehElement = source local vehPlate = getVehiclePlateText(source) local player = getElementData(source, "player") setTimer(function (vehicle, damageTimeCount) local health = getElementHealth(vehicle) - 250 local vehHealth = math.floor(health / 750 * 100) iprint("damageTimeCount: " .. damageTimeCount .. ", vehHealth 2: ", vehHealth) triggerServerEvent("healthToDb", getRootElement(), vehHealth, vehElement, vehPlate, player) end, 50, 1, source, damageTimeCount) end)
  22. onClientVehicleDamage seems to be more accurate but theres one thing that confuses and it happend on both events when the vehicle is 100 and hits a wall for first time it doesn't get his health and i have to hit again to start decreasing it(in script)
  23. As the title says onVehicleDamage doesn't register always.. what i mean is i have the following code addEventHandler("onVehicleDamage", getRootElement(), function(loss) local health = getElementHealth(source) - 250 local vehHealth = math.floor(health / 750 * 100) if vehHealth < 1 then setElementHealth(source, 250) end iprint("vehHealth: ", vehHealth) end) i have set the vehicle health showing as an integer from 1 to 100 and when it reaches below 0 it caughts in fire but when the vehicle is 0 and caughts up in fire sometimes the event works and restores the health to 250 which is 0(before it caught in fire) and sometimes not and the vehicle explodes. Does anybody knows why this happens
×
×
  • Create New...