-
Posts
1,050 -
Joined
-
Last visited
Everything posted by ViRuZGamiing
-
I have this piece of code in a onClientRender function but all my message are in 1 position. I've tried experimenting to get the 2nd one underneath it but then it just falls off my screen. (the Dx moves to the bottom) How can I make it so that my 2nd message (and next ones) are all below the previous one. for i, message in pairs(messages) do dxDrawText(message, 940, minHeight, 1230, (minHeight+(msgHeight*15)), tocolor(255, 255, 255, 255), 0.60, "bankgothic", "left", "top", true, true, false, false, false) end
-
That makes me stuck in my typing situation. My dxDraw is drawn but my input is (as expected) cancelled.
-
It might be because I did it server sided, let me try it client. EDIT: Nope still does
-
Actually onClientKey works better in my case because I use backspace and enter and such as well, newb didn't work #Alw7sh this is how I did it,
-
As I said 't' because t opens the chat
-
So can't I just unbind the chat? there is a MTA Hardcoded command 'chatbox' as far as I know. But unbindKey("t", "both", "chatbox") didn't do the trick sadly.
-
Woops, sorry my bad, I changed them. Now it indeed works. Thanks `again`
-
This helped me all the way to the end thx I've almost made an entire basic chat system in +/- 1 hour. Not that this is a problem but I keep getting 'Command of cvar unknown: chatbox' in my console. I used showChat(false) to hide to default one.
-
Oh so what I did was on press and release output it BTW you don't need to check for booleans to be true
-
I've edited it here; local input = "" local chatVisible = false function getChatInput (button) input = input..button end function drawChat() dxDrawRectangle(342, 648, 597, 29, tocolor(255, 255, 255, 255), false) dxDrawRectangle(343, 649, 595, 27, tocolor(0, 0, 0, 255), false) dxDrawLine(421, 652, 421, 672, tocolor(255, 255, 255, 255), 1, false) dxDrawText("CHAT:", 343, 651, 421, 674, tocolor(255, 255, 255, 255), 0.60, "bankgothic", "center", "center", false, false, false, false, false) dxDrawText(input, 430, 651, 935, 674, tocolor(255, 255, 255, 255), 0.60, "bankgothic", "left", "center", true, false, false, false, false) end function setChatVisible(state) if (state) then addEventHandler("onClientRender", root, drawChat) addEventHandler("onClientKey", root, getChatInput) toggleAllControls(false) chatVisible = true bindKey("escape") else removeEventHandler("onClientRender", root, drawChat) removeEventHandler("onClientKey", root, getChatInput) toggleAllControls(true) chatVisible = false end end function getChatVisible() if (chatVisible) then return true else return false end end addEvent("setChatVisible", true) addEventHandler("setChatVisible", getRootElement(), function() if (getChatVisible()) then setChatVisible(false) else setChatVisible(true) end end) the event setChatVisible is triggered by a bindKey added serverside onPlayerJoin: function bindChat (thePlayer) triggerClientEvent(thePlayer, "setChatVisible", thePlayer) end addEventHandler("onPlayerJoin", getRootElement(), function() showChat(source, false) bindKey(source, "t", "down", bindChat) end)
-
local input = "" function getChatInput (button) input = input..button end function drawChatInput() dxDrawText(input, 430, 651, 935, 674, tocolor(255, 255, 255, 255), 0.60, "bankgothic", "left", "center", true, false, false, false, false) end addEventHandler("onClientRender", root, drawChatInput) I tried this it almost works, the only problem is it outputs every key twice.
-
Is there a way to get the input of keys? I could make a table with all keys and bind them to a input function. But say for example if I press 'b' then b outputs in chat.
-
dbPoll failed; You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ''user' WHERE 'user_name' = 'Viruz'' at line 1
-
Changed it and still didn't add anything to my Phpmyadmin page
-
connection = dbConnect( "mysql", "dbname=mta;host=127.0.0.1", "mta", "***", "share=1" ) if (connection) then outputServerLog("Connected!") end function queryDb (query) local qh = dbQuery(connection, tostring(query)) local result = dbPoll(qh, -1) if result == nil then dbFree(qh) else return result end end addEventHandler("onPlayerConnect", getRootElement(), function(playerNick, playerIP, playerUsername, playerSerial, playerVersionNumber) nameSearch = queryDb("SELECT user_name FROM user WHERE user_name='"..playerNick.."'") if (nameSearch) then -- login else queryDb("INSERT INTO user ('user_name') VALUES ('"..playerNick.."')") queryDb("INSERT INTO user ('user_ip') VALUES ('"..playerIP.."') WHERE user_name='"..playerNick.."'") end end) So I'm trying some basic SQL, the connection works but it seems I can't anything to my database. Full image: http://prntscr.com/9vjx3b
-
Thx exactly what I needed I did need to put my A_I on PRIMARY tho else I couldn't create it.
-
Oh so you create it inside lua because I was trying to do this in the XAMPP Phpmyadmin panel.
-
There's something I don't seem to find any info about and that's about how to create tables in SQL, I have a database called 'mta' and a table called 'user' and I have a few things that I know, these things; user_name is varchar user_id is integer and A_I for the automatic numbering But apart from the name and type, what has to be specified?
-
We'll I'm try to open the trunk of a vehicle by pressing F so when a player is standing behind the vehicle the enter gets toggled and a new function get's binded. I am planning on making so that a vehicle has a owner and an ID so I could use those but I was trying to make this work as a standalone first.
-
function bindFunc(hitElement) if (getElementType(hitElement) == "player") then toggleControl(hitElement, "enter_exit", false) bindKey(hitElement, "f", "down", funcName) end end setTimer(function () for index, vehicle in pairs (getElementsByType("vehicle")) do if not (getElementData(vehicle, "marker")) then local x, y, z = getElementPosition(vehicle) vehMarker = createMarker(x, y, z, "cylinder", 2.0, 255, 0, 0, 255) attachElements(vehMarker, vehicle, 0, -3, -1) setElementData(vehicle, "marker", vehMarker) addEventHandler("onMarkerHit", vehMarker, bindFunc) -- I should need a way to pass the argument with this handler end end end, 6000, 0) Can I do this? addEventHandler("onMarkerHit", vehMarker, bindFunc(vehicle))
-
Yeah but the bindkey is not in the scope of the vehicle
-
You don't seem to get it, I am sorry to be rude but it seems you don't understand what I try to do. I want use (look at the bold text); for key,vehicle in ipairs(vehicles) do to be used inside 'bindFunc' from my last example. addEventHandler("onMarkerHit", vehMarker, bindFunc) So I can do this function bindFunc () use vehicle here end
-
What I eventually try to do is passing the 'vehicle' onto the 'bindFunc' function. setTimer(function () for index, vehicle in pairs (getElementsByType("vehicle")) do if not (getElementData(vehicle, "marker")) then local x, y, z = getElementPosition(vehicle) vehMarker = createMarker(x, y, z, "cylinder", 2.0, 255, 0, 0, 255) attachElements(vehMarker, vehicle, 0, -3, -1) setElementData(vehicle, "marker", vehMarker) addEventHandler("onMarkerHit", vehMarker, bindFunc) addEventHandler("onMarkerLeave", vehMarker, unbindFunc) end end end, 6000, 0)
-
when I enter a marker I need to know the vehicle attached to it and use it inside funcName as argument passed through the bindKey.