
Nikolay_888
Members-
Posts
25 -
Joined
-
Last visited
Everything posted by Nikolay_888
-
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.
-
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)
-
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.
-
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.
-
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?
-
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
-
--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?
-
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
-
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
-
Where to store password while registration not finished?
Nikolay_888 replied to Nikolay_888's topic in Scripting
Ok guys, thank you -
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
-
Hello. Can I use QuickBinder for MTA? If no, is the similar exist? Thank you
-
Ok, i understood, thank you!
-
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.
-
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.
-
Ok, thank you guys. And what about this: MySQLConnection mysql_connect ( string hostname, string username, string password, string database, [ int port=3306, string unix_socket=nil, string client_flags=""] ) Is it the same thing?
-
But this is SQLite
-
Hello. I want to learn to use MTA-MySQL module. In the forum, I searched this topic: viewtopic.php?f=148&t=42067&hilit=mysql But the topicstarter write: Is this tutorial not actual? I don't searched no more tutorials about MTA-MySQL. So how to learn this module? I don't want to use db functions, because I read that it is slow (with big amount of query). Thank you
-
I don't know, but I think there is an error in third string. Try this: local slot = getPedWeaponSlot ( source ) if slot == 0 or slot == 1 or slot == 8
-
Hello. I want to remove this grass too. How to do this now? May be there are a complete solutions? Into this and other topics I didn't find answer. Thank you ___ Screenshot with this grass in the 6 message in this topic.
-
Don't understand working function (player, command, ...)
Nikolay_888 replied to Nikolay_888's topic in Scripting
GTX, it works, thank you very much -
Hello. I know, functions in Lua can take variable number of arguments by (...) So I try this: function testSumm (thePlayer, command, ...) local s = 0 for i, n in pairs(arg) do s = s + n end outputChatBox (s, thePlayer) end addCommandHandler("summ", testSumm) But this functions works not well. For example, command "/summ 1 2 3" output into the chat 9, not 6. Where is mistake? Thank you
-
Thank you, GTX. I didn't know about this functions.
-
Hello. I want to script respawn player in the same place, where he wasted. I scripted this: function playerWasted () setTimer (function (source) local x,y,z = getElementPosition(source) spawnPlayer(source, x, y, z) end, 10000, 1, source) end addEventHandler ("onPlayerWasted", root, playerWasted) But this script doesn't work well in some situations. For example, if the player wasted in the blown up moving car or helicopter, getElementPosition returns coordinates, that was in the moment of blow, notwithstanding function run after timer 10 sec. So if the player wasted in flying helicopter, he will respawn in the sky. What to do to getElementPosition work well in these situations. Thank you.
-
Всем привет. Ребят, а как сделать спавн игрока на том же месте, где он умер? Представленный ниже код работает верно не во всех случаях, например, если игрок умер в взорвавшемся движущемся транспорте, то getElementPosition выдает позицию в момент взрыва, не смотря на то, что функция исполняется по таймеру через 10 сек. function playerWasted () setTimer (function (source) local x,y,z = getElementPosition(source) -- получаем позицию игрока spawnPlayer(source, x, y, z) end, 10000, 1, source) end addEventHandler ("onPlayerWasted", root, playerWasted)