Jump to content

DriFtyZ

Members
  • Posts

    73
  • Joined

  • Last visited

Everything posted by DriFtyZ

  1. if the vehicle health goes below 300 it caughts in fire, how to calculate the health in just integers 1-100 cuz i want to show it later on a gui
  2. if i don't subtract the loss it just writes a "1000" number in database no matter how many damage been done to the vehicle
  3. Hello there, i want to make a function where when the vehicle damages it syncs its health to the sqlite db.. It works quite a bit but the numbers are a bit different in database and in game Code Below: addEventHandler("onVehicleDamage", getRootElement(), function(loss) local vehHealth = math.floor((getElementHealth(source) / 10) - (loss / 10)) local owner = getElementData(source, "Owner") local getAccName = getAccountName(getPlayerAccount(owner)) local getPlate = getVehiclePlateText(source) local checkOwner = dbQuery(vehicleDb,"SELECT * FROM vehicles WHERE ownerName=? AND veh_plate=?", getAccName, getPlate) local checkOwnerResult = dbPoll(checkOwner, -1) if checkOwnerResult ~= 0 then dbExec(vehicleDb,"UPDATE vehicles SET veh_Health=? WHERE ownerName=? AND veh_plate=?", vehHealth, getAccName, getPlate) end end) the database connection works well but i don't know how to calculate exact vehicle health after loss to an integer number, any help appreciated!
  4. i saw that but its gone few years i think its been requested, is it abandoned?
  5. sorry i forgot to mention its most important to me and other car guys only. but why not use legit upgrades i mean i can replace hundreads of japanese cars but whats the matter if i can't customize them. I know you can make shaders and apply them to a texture but its not too nessecary as the other i said
  6. Hello Community, i have a question about mta sa. I see in wiki you can script anything you want but mta sa limits us to edit .ide files and doesn't have any functions about adding upgrade ids to vehicles... Many servers want to fake that by creating Objects and attach them to the cars as upgrade but they disable damage cuz objects are non damageable.. I wonder why mta sa doesn't have this (most important i think) feature? i want legit answer please.
  7. I have a question, i want to create a custom interior which will be a garage (or a warehouse in old need for speeds) which the player can interact with his car or select another in there but i don't how to yet any ideas?
  8. yep works like a charm thank you!
  9. thank you i was looking forward to use lua tables but couldn't find how.. im gonna try this out and let you know
  10. to be more specific when the user clicks the spawn button on gui it triggers the server event which is the follow: addEvent("spawnVehicleS", true) function spawnVehicleS ( player, pX, pY, pZ, vehNameS, vehPlateS ) if player and pX and pY and pZ and vehNameS and vehPlateS then if playerVeh1 then destroyElement(playerVeh1) end local accName = getAccountName(getPlayerAccount(player)) local vehicleQuery = dbQuery(vehicleDb,"SELECT * FROM vehicles WHERE ownerName=? AND veh_name=? AND veh_plate=?", accName, vehNameS, vehPlateS) local vehicleQueryResult = dbPoll(vehicleQuery, -1) if #vehicleQueryResult > 0 then for rid, row in ipairs (vehicleQueryResult) do local veh_id = row.veh_id local veh_plate = row.veh_plate local colR1 = row.colR1 local colR2 = row.colR2 local colR3 = row.colR3 local colG1 = row.colG1 local colG2 = row.colG2 local colG3 = row.colG3 local colB1 = row.colB1 local colB2 = row.colB2 local colB3 = row.colB3 local col_hs1 = row.col_hs1 local col_hs2 = row.col_hs2 local col_hs3 = row.col_hs3 local veh_Health = row.veh_Health playerVeh1 = createVehicle(veh_id, pX, pY, pZ, 0, 0, 0, veh_plate) local setVehicle1Color = setVehicleColor(playerVeh1,colR1,colG1,colB1,colR2,colG2,colB2,colR3,colG3,colB3, 0, 0, 0) local setVehicle1LightsColor = setVehicleHeadLightColor(playerVeh1, veh_hs1, veh_hs2, veh_hs3) local playerToVeh = warpPedIntoVehicle(player, playerVeh1) end end end end addEventHandler("spawnVehicleS", getRootElement(), spawnVehicleS) i know my problem is on the variable playerVeh1 but i don't know how to make a "unique" variable
  11. thank you syntrax i think i made it :~ somewhere and when i spawn a car it despawns someone else's
  12. yes i've made it WHERE ownerName=? AND veh_name=? AND veh_plate=?
  13. i make it to find the car through the licence plate i guess ill stick it for now unless i find some easier with less "lag or bandwidth" way than trigger server events and client to fetch and load data to menu
  14. you mean table.insert string on an empty table?
  15. i want to make vehicle ids but for the each player specific i mean if the user driftyz has 2 vehicle there should his name in the first column on the first 2 rows and then id 1 which means his first vehicle on the list and id 2 but if some other user buy a car i don't want him ta have the same id increasement as driftyz but 1 again as its gonna be his first car
  16. i tried to use primary keys, with auto increasement but how thats gonna help me with my previous question.
  17. true but what if i wanted to avoid that i mean i see in CIT server the vehicles have a row ID number in front of the name i just wanted to learn how this can be possible without creating tables for each player
  18. this is my vehicle menu if i want to find the vehicle for something that appears on the menu
  19. Hello fellas i have an important question about the databases in lua scripting, i have made a carshop system which stores the vehicles inside the database and i have made a menu which the user selects to spawn despawn his vehicle. if the user has 2 same vehicles how the script will know wich one from the database will pick? image of database:
  20. i did logged in and out many times everything works except the chatbox
  21. it is working but i have some questions 1. what are these _,acc function parameters used for? 2. these row,column tables lines, you made them so it will show in the chatbox the tables but chatbox doesn't show up anything
  22. forget the first column i mean the playerName column
  23. if i try that how would the script add the account name in the first index?
  24. okay this :~ starts confuses me its not adding things to database and its not debuging anything at all ffs function playerLogin(player) local playerAcc = getPlayerAccount(player) local accName = getAccountName(player) local playerQuery = dbQuery(connectionDb,"SELECT * FROM settings WHERE playerName=?", accName) local playerQueryResult = dbPoll(playerQuery, -1) if #playerQueryResult == 0 then outputDebugString(getPlayerName(player).." Creating new settings") local createPlayerIndex = dbExec(connectionDb, "INSERT INTO settings (playerName,carReflect,water,contrast,detail,sky,showFps) VALUES (?,?,?,?,?,?,?)", accName, 1, 1, 1, 1, 1, 1) if createPlayerIndex then outputDebugString(getPlayerName(player).." Creating new settings went successful.") else outputDebugString(getPlayerName(player).." Creating new settings failed check your db connection.") end end end addEventHandler("onPlayerLogin", resourceRoot, playerLogin) i fixed some things and still..
  25. well i made some changes and still still doesn't work(to add values in database if acc does not exist) new script as follow: function playerLogin(player) local playerAcc = getPlayerAccount(player) local accName = getAccountName(player) local playerQuerry = dbQuerry(connectionDb,"SELECT * from settings WHERE playerName=?", accName) local playerQuerryResult = dbPoll(playerQuerry, -1) if #playerQuerryResult == 0 then local createPlayerIndex = dbExec(connectionDb, "INSERT INTO settings (playerName,carReflect,water,contrast,detail,sky,showFps) VALUES (?,?,?,?,?,?,?)", accName, 1, 1, 1, 1, 1, 1 ) end end addEventHandler("onPlayerLogin", resourceRoot, playerLogin)
×
×
  • Create New...