Jump to content

Nikolay_888

Members
  • Posts

    25
  • Joined

  • Last visited

Nikolay_888's Achievements

Advanced Member

Advanced Member (8/54)

0

Reputation

  1. Function someFunction shows using getdataco in real situation. That is getdataco possible use in another situations. So, first coroutine need to use received data after receive.
  2. Oh, I did it. Thank you very much, JR10. This is my code. It works, but is this code right? I used coroutines first time and try 1000 variants function someFunction () playerco = coroutine.create(function (data) outputChatBox (data, root) end) coroutine.resume (getdataco, 57, 'name') end --- getdataco = coroutine.create (function (id, dataDB) local data = false function querrrry () local query1 = dbQuery (function (query) local poll, num_rows = dbPoll (query, 0) if poll then if num_rows == 1 then for _, row in pairs ( poll ) do data = row[dataDB] coroutine.resume (getdataco) end end end end, players_db, "SELECT ?? FROM players WHERE id=?", dataDB, id) end querrrry () coroutine.yield () coroutine.resume (playerco, data) end)
  3. Noki, i read that using dbQuery without callback function will freeze server. I searched this topic viewtopic.php?f=91&t=86184&p=780099&hilit=coroutine#p780099 This is the same situation, but I can't use this code for my situation yet.
  4. Hello. I create a function, that return data from database. function takePlayerDataFromDB (id, data) if id and data then local receivedData = false local query1 = dbQuery (function (query) local poll, num_rows = dbPoll (query, 0) if poll then if num_rows == 1 then for _, row in pairs ( poll ) do receivedData = row[data] end end end end, players_db, "SELECT ?? FROM players WHERE id=?", data, id) return receivedData end end a = takePlayerDataFromDB (5, 'name') The problem is line 14 runs faster then line 9, and function returns false. And I don't know how to use 'return' right in callback function. I would be grateful for help.
  5. What about to use dbQuery instead dbExec. For example: addaccount = dbQuery( pl_con, "INSERT INTO players VALUES (?,?)", id, name) local poll, num_rows = dbPoll (addaccount, -1) if poll and num_rows == 1 then --register OK else --register fail end It works in my situation, but is it a right way? I mean is this code will cause errors or problems in another place?
  6. Hello. I read: 'To update values in database, we need to use dbExec.' But how can I check, executes this dbExec query or not, if this function (from wiki) So, if the connection is correct, and the query is incorrect, function returns true. How to check, is values updated/inserted with dbExec? Thank you
  7. --server function createVehicleForPlayer(thePlayer, command, vehicleModel) local x,y,z = getElementPosition(thePlayer) x = x + 5 local createdVehicle = createVehicle(tonumber(vehicleModel),x,y,z) end addCommandHandler("cv", createVehicleForPlayer) function gVehicleStartEnter (player, seat) if seat == 0 and getVehicleOccupant (source, 0) then cancelEvent () outputChatBox ('stop it', player) end end addEventHandler ('onVehicleStartEnter', root, gVehicleStartEnter, _, 'high') When I try to enter to empty created vehicle, event cancelled. And i try to modify eventHandler like this: function gVehicleStartEnter (player, seat) if seat == 0 and getVehicleOccupant (source, 0) then cancelEvent () outputChatBox ('stop it', getVehicleOccupant (source, 0)) end end addEventHandler ('onVehicleStartEnter', root, gVehicleStartEnter, _, 'high') And now it output chat message to me What is wrong?
  8. Hello I want to warp ped into vehicle with animations. setPedControlState (ped, 'enter_exit', true) doesn't work, and I read that it is not a bug. So we need to use warpPedIntoVehicle and setPedAnimation. In this way, we need to calculate position of vehicle door very accurate (I think that for each car model there is different position), and with setPedControlState (ped, 'forwards', true) move ped to the door. But in the game, when we press control 'enter_exit', positions of vehicle door calculate automatically and player go to the door. Is there any way to use this for peds? Thank you
  9. Hello guys. Now I try to send mails too. I don't know php well. I installed XAMPP, downloaded MTA-SDK and unzip it to 'xampp - htdocs - mta_sdk' (as in this tutorial). What I need to do then? Thank you
  10. Hello. I create a registration system. In GUI player 1) read rules 2) choose skin 3) set password 4) confirm email. Then this data add to database (mysql). Where to store password when player enter it in GUI? My versions: 1) setElementData clientside 2) triggerServerEvent to setElementData serverside 3) store in variable clientside 4) create a second database to store accounts, that not finished registration, and 4.1) if registration finished, copy data to main db, delete row in second db 4.2) if registration not finished, delete row in second db. I'm looking for script security. Thank you
  11. Hello. Can I use QuickBinder for MTA? If no, is the similar exist? Thank you
  12. Ok, thank you, I decided to use db functions. But I have new question: Why need to use elementData for players, if there is a database? For example: I need to save a value of player money. There is a column 'money' in the db 'players'. On server starts, it connects to db. Then player join to the server, with setPlayerMoney I set value from db. Then player spend his money, we use setPlayerMoney and set new value into db.
  13. Hello. What is the best choice: 1. Create one database and create 2 table (players, vehicles) in this db 2. Create one database with one table for players, and one database with one table for vehicles? Why? Thank you.
×
×
  • Create New...