Jump to content

HereIsTheOne

Members
  • Posts

    4
  • Joined

  • Last visited

HereIsTheOne's Achievements

Vic

Vic (3/54)

0

Reputation

  1. Hello! I'm creating a character selector using MySQL and I have some troubles. I use this to get the account players: local accData = singleQuery("SELECT * FROM players WHERE account=? LIMIT 3",string.lower(account)) for i=3,1,-1 do if(accData.username) then outputChatBox(accData.username,source,255,0,0, true) -- used to check results end end I'm using simple MySQL functions, these is the singleQuery function: function singleQuery(str,...) if (connection) then local query = dbQuery(connection,str,...) local result = dbPoll(query,-1) if (type(result == "table")) then return result[1] else return result end else return false end end It's normal that these function returns only one result. What I want is to list all of the results. If I have 4, i want to do a for loop with the 4 results. Anyone knows how I can modify this function to make another one called, for example, multipleQuery(str,..)? I don't know if it's possible to do something like "accData[1]" for character 1, "accData[2]" for character 2, etc.. Thanks!
  2. Yes, It's included in meta.xml No, thanks for asking.
  3. Hello, I'm making a RP Gamemode and I'm creating the Character Creation System. When I login I go to the character selector, but I don't know what I'm doing wrong, I can't 'connect' or pass information througth resources. Here is the code: LOGIN_SERVER.lua [Resource login] -- ... other code function login(username, password) local account = getAccount(string.lower(username), password) logIn (source, account, password) setPlayerName(source, username) outputChatBox("#00BBFFServer:#FFFFFF Welcome again, #00BBFF"..getPlayerName(source),source,0,255,0, true) if (accData.players == 0) then -- accData gets rows from MySQL, it works fine setTimer ( delayedChat, 1000, 1, "#00BBFFServer:#A60019 Opening the creator...") setTimer ( startCreator, 2000, 1, getResourceRootElement(getThisResource()) ) end end function startCreator () exports.creator:makeCreator() end -- .. more code CREATOR_CLIENT.lua [Resource creator] function createWindow() outputChatBox ( "WE ARRIVE!!" ) end addEvent( "makeWindow", true ) addEventHandler( "makeWindow", getLocalPlayer(), createWindow ) CREATOR_SERVER [Resource creator] function startCreator ( ) triggerClientEvent ( getResourceRootElement(getThisResource()), "makeWindow", getResourceRootElement(getThisResource()) ) end Thare's an easiest way to make it or I'm going well with these system? At these time, the outputmessage don't show and the server output is fine, no error messages. Someone can help me? Thanks!
  4. Hello! I'm new on the MTA community, I'm coming from SAMP. Actually I'm developing an RP Server, and I'm new here so I have some questions. I'm developing a RP Server using MySQL. For the login I'm using, at the end, this function: addEvent("onPlayerAttemptLogin",true) addEventHandler("onPlayerAttemptLogin",root, function(username,password) if (singleQuery("SELECT * FROM accounts WHERE username=? LIMIT 1",string.lower(username))) then local accData = singleQuery("SELECT * FROM accounts WHERE username=? AND password=? LIMIT 1",string.lower(username),sha256(password)) if (accData) then setPlayerName(source, username) outputChatBox("Welcome again, "..getPlayerName(source),source,0,255,0) setElementData(source,"accountID",accData.id) setElementData(source,"accountUsername",accData.username) fadeCamera(source,false,1.0,0,0,0) setTimer(fadeCamera,2000,1,source,true,1.0,0,0,0) setCameraTarget(source,source) showChat(source,true) spawnPlayer(source,accData.x,accData.y,accData.z+1,accData.rotation,accData.skin,accData.interior,accData.dimension) local weapons = fromJSON(accData.weapons) if (weapons) then for k,v in pairs(weapons) do giveWeapon(source,tonumber(k),tonumber(v)) end end if (accData.health == 0) then killPed(source) else setElementHealth(source,tonumber(accData.health)) end setPedArmor(source,tonumber(accData.armor)) setPlayerMoney(source,tonumber(accData.money)) setElementData(source,"isGuestAccount",false) triggerClientEvent(source,"closeLoginWindow",source) triggerEvent("onAccountPlayerLogin",source,accData.id,accData.username) log(source) --store the login data. else outputChatBox("The username or the passwords are incorrect.",source,255,0,0) end else outputChatBox("The username entred does not exist.",source,255,0,0) end end) The question is, is there a way to set the username without using setPlayerName(source, username) to prevent this?: Or there's a way to prevent the text message? Another question is, how I can share data from scripts? For example I want to link the login with a house system (for example) that is in another resource file. There's a way to do it? Thanks!
×
×
  • Create New...