-
Posts
642 -
Joined
-
Last visited
Posts posted by Lloyd Logan
-
-
Remove the event handler.
removeEventHandler
Thanks
-
Hi,
just as the title says, a quick question!
If I'm showing the dxDrawText, how do i hide it?
Lloyd
-
I'll try that!
Is
dbExec ( server, "UPDATE accounts SET money = ? WHERE serial = ?", moneys, firstserial )
All you changed?
-
What do you mean by "save the serial as nil"? the setMoney function is meant to load the money, so how can it "save the serial"?
Sorry there was some blatant mistakes in that code!
I'm now able to save the money when the player quits, and load it when they join, so now I am stuck on how to update it if their info is already in the table!
function submitReg() firstserial = getPlayerSerial(source) moneys = getPlayerMoney(source) local data = dbPoll(dbQuery(server, "SELECT money FROM accounts WHERE serial = ?", firstserial), -1) if data and type (data) == "table" and #data > 0 then dbExec( server, "UPDATE accounts SET money=`"..moneys.."` WHERE serial = '"..firstserial.."'" ) else dbQuery ( server, "INSERT INTO accounts (serial, money) VALUES (?, ?)", tostring (firstserial), tostring (moneys) ) end end addEventHandler( "onPlayerQuit", root, submitReg )
-
server = dbConnect ( "mysql", "dbname=servermta;host=127.0.0.1","root")
dbExec(server, "CREATE TABLE IF NOT EXISTS accounts (serial TEXT NOT NULL, money INT NOT NULL)")
function submitReg() firstserial = getPlayerSerial(source) moneys = getPlayerMoney(source) local data = dbPoll(dbQuery(server, "SELECT money FROM accounts WHERE serial = ?", firstserial), -1) if data and type (data) == "table" and #data > 0 then dbExec( server, "UPDATE `accounts` SET `money`=`"..moneys.."`" ) else dbQuery ( server, "INSERT INTO accounts (serial, money) VALUES (?, ?)", tostring (theserial), tostring (themoney) ) end end addEventHandler( "onPlayerQuit", root, submitReg ) exports.scoreboard:addScoreboardColumn("Money") function setMoney() local Serial = getPlayerSerial(source) local data = dbPoll(dbQuery(server, "SELECT money FROM accounts WHERE serial = ?", Serial), -1) if data and type(data) == "table" then setPlayerMoney(source, data[1]["money"]) setElementData(source, "Money", data[1]["money"]) else outputChatBox("You have not previously logged in!", getRootElement(), 255, 0, 0) end end addEventHandler("onPlayerJoin", root, setMoney)Why does this save the serial as nil and money as 0?
-
No, When you select the row there might be more than one row so we select the first row in the table which [1].
Oh Thanks, but what happens now is, everytime the player joins, a new row is created instead of checking for previous log ins and updating them! So far is this
checkforserial = dbQuery (server, "ALTER TABLE accounts, ADD CHECK ('"..theserial.."'>0)") if (checkforserial == false) then dbQuery ( server, "INSERT INTO accounts (serial, money) VALUES (?, ?)", tostring (theserial), tostring (themoney) ) else
-
-
That's my code
function setMoney() serial = getPlayerSerial(source) local data = dbPoll(dbQuery(server, "SELECT 'money' FROM 'accounts' WHERE serial = '"..serial.."' "), -1) setPlayerMoney(player, data[1]["money"]) if data then local curmoney = getPlayerMoney(source) exports.scoreboard:addScoreboardColumn("Money") setElementData(thePlayer,"Money",curmoney,true) end end addEventHandler("onPlayerJoin", root, setMoney)
It gives the error; attempt to index local 'data' "a boolean value"
-
You should first get the position of the billboard.
Then setCameraTarget, I do not know what you mean by the second point, but I think you me so it happens realistically, if that's what you mean, then it should already do it after setCameraTarget (Remember, to be able to set Camera target as x, y ,z it must be Client Side)
-
You can use WHERE clause to select specific row.
So how would i setPlayerMoney when retrieving this information?
local playermoney = dbQuery ( server, "SELECT 'money' FROM 'accounts' WHERE serial = '"..serial.."' " )
local query = dbQuery ( handler, "SQL STRING HERE" ) local data = dbPoll ( query, - 1 ) -- -1 = wait for the result, freezes server until it has the result. if ( type ( data ) == "table" ) then print ( data [ 1 ].myColumnName ) end
I honestly don't understand at all, surely once I retrieved the info from the money index
local playermoney = dbQuery ( server, "SELECT 'money' FROM 'accounts' WHERE serial = '"..serial.."' " )
I can simply apply it to setPlayerMoney
-
You can use WHERE clause to select specific row.
So how would i setPlayerMoney when retrieving this information?
local playermoney = dbQuery ( server, "SELECT 'money' FROM 'accounts' WHERE serial = '"..serial.."' " )
-
-
-
Have you already got the MySQL connected?
dbConnect
If you want to get certain value you need to use SELECT.
I used SELECT, but how would i select something from a specific row?
-
If you are using it without a loop, then you need to include the [ 1 ] before the column name from which you wish to obtain it's value, this "1" represents the index.
I'm totally stuck, i'm only trying to get some values from mySQL, maybe i'm going about it wrong? I stored it in mySQL, now i'm trying to take a certain value (money ) out.
-
local query = dbQuery ( handler, "SQL STRING HERE" ) local data = dbPoll ( query, - 1 ) -- -1 = wait for the result, freezes server until it has the result. if ( type ( data ) == "table" ) then print ( data [ 1 ].myColumnName ) end
So how would I use this in terms of
setPlayerMoney(something.somthing?)
Thanks also!
-
I was looking at someones script and saw this;
local result = mysql_query ( database ,"SELECT * FROM `accounts` WHERE `serial` = '"..serial.."'") if result then while true do local row = mysql_fetch_assoc(result) if not row then break end setElementPosition ( source, row.x, row.y, row.z)
So in order for him to use row.blah blah, he used mysql_query then local row = mysql_fetch_assoc
My problem is, i'm using dbQuery, so how would i create one equal to
local row = mysql_fetch_assoc(result) if not row then break end setElementPosition ( source, row.x, row.y, row.z)
except for dbQuery
Thanks!
-
Thanks guys, I'll try both when I'm free and get back to you all!
-
Why is this creating an account row and password row, but its putting in blank values e.g. accounts || Password
both just equal blank!
CLIENT
function checkRegField() local inputusernamereg = guiGetText(GUIEditor.edituserreg) local inputpasswordreg = guiGetText(GUIEditor.editpassreg) triggerServerEvent("submitRegister", localPlayer, inputusernamereg, inputpasswordreg) end
SERVER
function submitReg() dbExec(server, "CREATE TABLE IF NOT EXISTS accounts (accountname TEXT NOT NULL, password TEXT NOT NULL)") new = dbExec(server, "INSERT INTO accounts (accountname, password) VALUES (?,?)", inputusernamereg, inputpasswordreg) output = outputChatBox("You have successfully created an account!") triggerClientEvent("closedok", getRootElement()) triggerClientEvent("onclose", getRootElement()) end
-
Try this;
function spawnOnDeath () setTimer ( function() spawnPlayer (source, 0, 0, 5) fadeCamera (source, true) setCameraTarget (source, source) end, 5000, 1 ) end addEventHandler("onPlayerWasted", getRootElement(), spawnOnDeath)
Though remember, 'play' is the default game mode, so you may have to disable it in order for this to work!
-
I've downloaded a GateMaker or something like that, and I've gotten to know it and stuff, now I've experienced two bugs that ruin that resource, and I beg all of you to help me.
Now here's the drill; When I add the gate for "GroveRefuge" it doesn't even add gate, even when I reload the resource/restart server. When I don't add for team, the gate itself, opens, but does not close.
I beg all of you help me, please!
Any errors from console/chat?
-
I don't mean command.
I mean when i click ex. "B" button on the keyboard, flashlight will be turn on/off.
In this script first i must type /flashlight command to enable.
You type in the chat box
/bind b flashlight
After this, when you click "b" the flashlight will turn on and off
-
Hey all, today I got a problem.
I was mapping in my local server, when I got crashed (IDK why) but the problem is, when I open my map how with race mode, all the things work fine, but when I open with editor, Many of that things are missing.
I reinstalled the server and still ocurring the same problem.
Things I tried.
- Change the name of folder and .map (Editing the meta.xml too)
- Send to my friend the map (persist the problem)
I need help please, I need help please.
My Skype: dani-bolivia.
Regards.
Any Errors?
-
Hi guys, i got the question: How to set bind to turn on/off the flashlight, without use /flashlight command?
https://community.multitheftauto.com/ind ... ls&id=6858
can be another script, but with bind function and without command runs.
Do you mean;
INGAME
/bind flashlight
Is that what you mean?
What's wrong with this?
in Scripting
Posted
Why doesn't this set the matrix of the camera? (CLIENT)