Cronoss Posted February 17, 2022 Share Posted February 17, 2022 (edited) Hello everyone, Well, I'll try to explain this, I'm not english speaker so I hope you understand what I'm about to say; I want to make possible save TWO different lines of information into my msql table for one account. This is for "character selection" for my RP server, I want to make possible the creation of two characters, and the main problem is that the info saves, but I don't know how to make a difference between the first character and the second one... the parameter to "identify" both characters. This is an example of what I'm talking about, When the player presses ">" into the "character selection" gui, this server event is triggered, so if the player have a second character it will show the second character skin, if not, it will set the skin 0, and give the option to create a second character: function check2Char() local playerAccount = getPlayerAccount(source) if(playerAccount) then if(isGuestAccount(playerAccount)) then return end end local nombre = getAccountName(playerAccount) local check = exports.mysql:_Query("SELECT * FROM characters WHERE cuenta=? LIMIT 1", nombre) if (check) then if(#check > 0) then for _,column in ipairs(check) do ---------------------don't know what parameter introduce here if (parameter==0) then setElementModel(source, 0) ---------- This is because the login-panel remembers the first character skin and set it in "character selection", so, if this "check" thing it's 0, then the second character doesn't exist, the model 0 is for the skin selection (prevent bugs) triggerClientEvent(source, "createCharacter", source) ----This would trigger the same "character creation" function that was used for the first character else rememberData() ---if the second character exists, then other function it's called (it remember the second character skin for the character-selection) end end end end addEvent("check2", true) addEventHandler("check2", getRootElement(), check2Char) PD: If it's still confusing to understand, I'm talking about to a parameter that would help to make the difference between the first and the second character, so if I don't want to "call" the first character info, then it only would affect the second character info Edited February 17, 2022 by Cronoss Link to comment
marcelluss Posted February 18, 2022 Share Posted February 18, 2022 if you need a unique key, then why not generate it? For example, get the player's time and add a random value to it at the end? or the player element itself? And then hase it all in md5? md5(toJSON(getRealTime())..""..math.random(0, 5000)) else md5(toJSON(getRealTime())..""..localPlayer) -- client side else element player for server side 1 Link to comment
Cronoss Posted February 18, 2022 Author Share Posted February 18, 2022 (edited) Solved note: I didn't tried marcellus idea. I didn't read the message till I finished the character system, just in case another person have the same problem and think that I tested the idea above Edited February 18, 2022 by Cronoss Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now