
Extinction
Members-
Posts
31 -
Joined
-
Last visited
Everything posted by Extinction
-
Thank you this one is work
-
SERVER SIDE function getCharacters() local result = {} local query = dbQuery(db, "SELECT * FROM characters WHERE account=?", getPlayerUsername(source)) result = dbPoll(query,-1) dbFree(query) if #result > 0 then triggerClientEvent(client,"setCharacters",client,result) else triggerClientEvent(client,"setCharacters",client,{}) end end addEvent("getCharacters",true) addEventHandler("getCharacters", root, getCharacters) CLIENT SIDE charGrid = guiCreateGridList(0.37, 0.32, 0.31, 0.25, true) guiGridListAddColumn(charGrid, "id", 0.3) guiGridListAddColumn(charGrid, "name", 0.3) guiGridListAddColumn(charGrid, "skin", 0.3) guiSetVisible(charGrid, false) guiSetVisible(playBtn, false) function setData(tab) for i=1,#tab do local row = guiGridListAddRow ( charGrid ) guiGridListSetItemText ( charGrid, row, 1, tab[i]['id'] , false, false ) guiGridListSetItemText ( charGrid, row, 2, tab[i]['name'] , false, false ) guiGridListSetItemText ( charGrid, row, 3, tab[i]['skin'] , false, false ) end end addEvent("setCharacters",true) addEventHandler("setCharacters",root,setData) ------------------------ function onClick() if source == characters then triggerServerEvent("getCharacters",getLocalPlayer()) end end addEventHandler("onClientGUIClick", root, onClick) everytime i will click on characters button, it will keep adding more rows of the same character again and again, how can i fix this issue?
-
@Anubhav Source won't work in client sided script?
-
Still doesnt make a difference, i tried this
-
CLIENT SIDE ------------------------ --- Create Character --- submitCreate = guiCreateButton(0.38, 0.57, 0.30, 0.05, "Create Character", true) lblCharName = guiCreateLabel(0.47, 0.33, 0.08, 0.04, "Charactername", true) charHeight = guiCreateLabel(0.47, 0.40, 0.08, 0.04, "Height: 150 CM", true) charWeight = guiCreateLabel(0.56, 0.40, 0.08, 0.04, "Weight: 50 KG", true) charGender = guiCreateLabel(0.47, 0.47, 0.04, 0.02, "Gender:", true) charMale = guiCreateCheckBox(0.47, 0.49, 0.04, 0.02, "Male", false, true) charFemale = guiCreateCheckBox(0.52, 0.49, 0.05, 0.02, "Female", false, true) charEdit = guiCreateEdit(0.47, 0.36, 0.15, 0.03, "", true) skinGrid = guiCreateGridList(0.38, 0.33, 0.08, 0.18, true) guiGridListAddColumn(skinGrid, "Skins", 0.9) for i = 1, 3 do guiGridListAddRow(skinGrid) end guiGridListSetItemText(skinGrid, 0, 1, "1", false, false) guiGridListSetItemText(skinGrid, 1, 1, "2", false, false) guiGridListSetItemText(skinGrid, 2, 1, "3", false, false) heightScroll = guiCreateScrollBar(0.47, 0.43, 0.07, 0.02, true, true) weigthScroll = guiCreateScrollBar(0.56, 0.43, 0.07, 0.02, true, true) guiSetVisible(skinGrid,false) guiSetVisible(submitCreate,false) guiSetVisible(lblCharName,false) guiSetVisible(charHeight,false) guiSetVisible(charWeight,false) guiSetVisible(charGender,false) guiSetVisible(charMale,false) guiSetVisible(charFemale,false) guiSetVisible(charEdit,false) guiSetVisible(heightScroll,false) guiSetVisible(weigthScroll,false) ------------------------ function createCharacterFunction() if source == submitCreate then local charname = guiGetText(charEdit) if guiCheckBoxGetSelected (charMale) then local gender = "male" elseif guiCheckBoxGetSelected (charFemale) then local gender = "female" local skin = guiGridListGetItemText ( skinGrid , guiGridListGetSelectedItem ( skinGrid ), 1 ) end end triggerServerEvent("createCharacter", source, charname, gender, skin) end addEventHandler("onClientGUIClick", root, createCharacterFunction) SERVER SIDE function createCharacter(charname, gender, skin) if charname and gender and skin then local query = dbQuery(db, "INSERT INTO characters (name, gender, skin, account) VALUES(?, ?, ?, ?)", charname, gender, skin, getPlayerUsername(client)) if query then outputDebugString("Updates characters.") else outputDebugString("Updating charactes failed.") end end end addEvent("createCharacter", true) addEventHandler("createCharacter", root, createCharacter) Nothing is outputted in debug when I click the button createCharacter, nothing in debug, no error
-
So if I did something like this, would it work - function checkAccounts(username) local sqlConnect = dbConnect("sqlite", "test.db") local querryH = dbQuery(sqlConnect, "SELECT * FROM accounts WHERE username = ?", username) if querryH == "Extinction" then neededData = dbPoll(querryH, -1) outputChatBox("Username was found, listing all current usernames: ", source) outputChatBox(querryH) --- To list all the usernames in DB? else outputChatBox("Username was not found", source) dbFree(querryH) end checkAccounts()
-
Oh, I see. So what would be an example of dbFree and dbPoll, is there any explained example you guys can share?
-
What's the difference between dbExec and dbQuery, looks like they both do the same job to me?
-
1. What does dbPoll exactly do? 2. What does dbFree exactly do? 3. How would I put data from sql into a client side script, what functions would i need? And are there any explained examples?
-
So how would I make the player login, or check if their login credentials are valid?
-
So like this - function register(usernamem, password) if client then if username ~= nil and password ~= nil then local query = dbQuery(database, "SELECT * FROM accounts WHERE username = ?", username) local result = dbPoll(query,-1) if #result > 0 then outputChatBox("Account exists", client) else outputChatBox("Account not exists", client) end end end end addEvent("register", true) addEventHandler("register", getRootElement, register)
-
So like this - function register(username, passowrd) if username ~= nil and password ~= nil then local query = dbQuery(database, "SELECT * FROM accounts WHERE username = ? AND password = ?", username, password) if query > 0 then outputChatBox("Account exists", source) else ----- end end addEvent("register", true) addEventHandler("register", root, register)
-
I'm working on a MySQL based login, and I am making my register function, I want to check if the username already exists in the database - function register(username, passowrd) if username ~= nil and password ~= nil then local query = dbQuery(database, "SELECT * FROM accounts WHERE username = ? AND password = ?", username, password) -- How do I check if the username already exists end end addEvent("register", true) addEventHandler("register", root, register)
-
local screenW, screenH = guiGetScreenSize() addEventHandler("onClientRender", root, function() dxDrawRectangle(screenW * 0.3445, screenH * 0.0000, screenW * 0.3117, screenH * 0.0472, tocolor(255, 37, 37, 151), false) dxDrawRectangle(screenW * 0.3445, screenH * 0.0472, screenW * 0.3117, screenH * 0.0069, tocolor(255, 255, 255, 255), false) dxDrawRectangle(screenW * 0.3500, screenH * 0.0083, screenW * 0.0641, screenH * 0.0319, tocolor(113, 0, 0, 226), false) dxDrawRectangle(screenW * 0.4297, screenH * 0.0083, screenW * 0.0641, screenH * 0.0319, tocolor(113, 0, 0, 226), false) dxDrawRectangle(screenW * 0.5078, screenH * 0.0083, screenW * 0.0641, screenH * 0.0319, tocolor(113, 0, 0, 226), false) dxDrawRectangle(screenW * 0.5875, screenH * 0.0083, screenW * 0.0641, screenH * 0.0319, tocolor(113, 0, 0, 226), false) dxDrawText("1", screenW * 0.3500, screenH * 0.0083, screenW * 0.4133, screenH * 0.0403, tocolor(255, 255, 255, 255), 0.90, "default-bold", "center", "center", false, false, false, false, false) dxDrawText("2", screenW * 0.3500, screenH * 0.0083, screenW * 0.4133, screenH * 0.0403, tocolor(255, 255, 255, 255), 0.90, "default-bold", "center", "center", false, false, false, false, false) dxDrawText("3", screenW * 0.4297, screenH * 0.0083, screenW * 0.4930, screenH * 0.0403, tocolor(255, 255, 255, 255), 0.90, "default-bold", "center", "center", false, false, false, false, false) dxDrawText("4", screenW * 0.5078, screenH * 0.0083, screenW * 0.5711, screenH * 0.0403, tocolor(255, 255, 255, 255), 0.90, "default-bold", "center", "center", false, false, false, false, false) dxDrawText("5", screenW * 0.5875, screenH * 0.0083, screenW * 0.6508, screenH * 0.0403, tocolor(255, 255, 255, 255), 0.90, "default-bold", "center", "center", false, false, false, false, false) end ) I want to make this come from the top, to down. like this - So it comes down from the top of the screen, down to 'DX'.
-
I'm not sure, nothing is outputted in the debug, and it's just stuck in one place.
-
dxDrawRectangle(screenW * 0.623 + 5, screenH * 0.2306, screenW * 0.020 - 5, screenH * 0.512, tocolor(118, 0, 0, 50)) if (moveY <= -540) then scrollerHeight = scrollerHeight - 10 else scrollerHeight = 40 end dxDrawRectangle(815-scrollerWidth + 5, 170+(math.abs(moveY)/fullScrolled)*fitHeight, scrollerWidth, scrollerHeight, tocolor(255, 12, 0, 50)) end end I'm trying to cut down the height of the scroller everytime it hits the end the DX Rectangle at the top, it'll start to decrease the height of the scroller, and not let it go out. I think I'm doing it wrong.
-
Works, one more question, how would I make a scrollbar that functions with this?
-
Shows, but no outputs in debug, and I can't scroll to show the rest.
-
Sorry didn't understand a word you said, maybe with an explained example?
-
How do I make it scroll now? so players scroll down and see the other text
-
local screenW, screenH = guiGetScreenSize() showCursor(true) addEventHandler("onClientRender", root, function() dxDrawRectangle(screenW * 0.3445, screenH * 0.2042, screenW * 0.3016, screenH * 0.5528, tocolor(255, 255, 0, 82), false) dxDrawRectangle(screenW * 0.3445, screenH * 0.7569, screenW * 0.3016, screenH * 0.0069, tocolor(255, 255, 0, 156), false) dxDrawRectangle(screenW * 0.3445, screenH * 0.1750, screenW * 0.3016, screenH * 0.0292, tocolor(255, 255, 0, 156), false) dxDrawText("Top Menu", screenW * 0.3438, screenH * 0.1750, screenW * 0.6461, screenH * 0.2042, tocolor(255, 255, 255, 255), 0.80, "default-bold", "center", "center", false, false, false, false, false) dxDrawText("Welcome to Test v1 - checking script, \ntoday you will be learning how\nWelcome to Test v1 - checking script, \ntoday you will be learning how\nWelcome to Test v1 - checking script, \ntoday you will be learning how\nWelcome to Test v1 - checking script, \ntoday you will be learning how\nWelcome to Test v1 - checking script, \ntoday you will be learning how\nWelcome to Test v1 - checking script, \ntoday you will be learning how\nWelcome to Test v1 - checking script, \ntoday you will be learning how\nWelcome to Test v1 - checking script, \ntoday you will be learning how\nWelcome to Test v1 - checking script, \ntoday you will be learning how\nWelcome to Test v1 - checking script, \ntoday you will be learning how\nWelcome to Test v1 - checking script, \ntoday you will be learning how\nWelcome to Test v1 - checking script, \ntoday you will be learning how\nWelcome to Test v1 - checking script, \ntoday you will be learning how\nWelcome to Test v1 - checking script, \ntoday you will be learning how\nWelcome to Test v1 - checking script, \ntoday you will be learning how\n", 455, 165, 813, 620, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, false, false, false) dxDrawRectangle(screenW * 0.3531, screenH * 0.2306, screenW * 0.2852, screenH * 0.5125, tocolor(201, 0, 0, 0), false) end ) I want to make it so when the dxDrawText hits the end of dxDrawRectangle(screenW * 0.3531, screenH * 0.2306, screenW * 0.2852, screenH * 0.5125, tocolor(201, 0, 0, 0), false) it cuts off the text, and then the person has to use his mouse to scroll down. How can i do this?
-
it outputs number 1 as 2
-
Just displays a white rectangle, even though I've entered things into the table. Edit: Needed to change text color How can I click something on the combo box, and then it outputs the message in outputchatbox e.g. click number 1 = outputChatBox("Clicked 1")
-
dxDrawRectangle(100, 100, 100, testItems > drawItems and drawItems*15 or #testItems*15) Attempt to compare number with table