Jump to content

Extinction

Members
  • Posts

    31
  • Joined

  • Last visited

Details

  • Gang
    Extinction

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Extinction's Achievements

Rat

Rat (9/54)

0

Reputation

  1. 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?
  2. @Anubhav Source won't work in client sided script?
  3. Still doesnt make a difference, i tried this
  4. 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
  5. 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()
  6. Oh, I see. So what would be an example of dbFree and dbPoll, is there any explained example you guys can share?
  7. What's the difference between dbExec and dbQuery, looks like they both do the same job to me?
  8. 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?
  9. So how would I make the player login, or check if their login credentials are valid?
  10. 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)
  11. 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)
  12. 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)
  13. 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'.
  14. I'm not sure, nothing is outputted in the debug, and it's just stuck in one place.
×
×
  • Create New...