Jump to content

Cronoss

Members
  • Posts

    173
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by Cronoss

  1. Now the console send me an error "dbPoll failed" when I quit to save the data mysql resource: function _Query( ... ) if connection then local query = dbQuery(connection, ... ) local result = dbPoll(query,-1) -------here return result else return false end end
  2. I just figured out that the table doesn't uptade the data, that's why x,y,z doesn't work correctly I think the problem it's here: function recordarData() local playerAccount = getPlayerAccount(source) if(playerAccount) then if(isGuestAccount(playerAccount)) then return end end local x, y, z = getElementPosition(source) local money = getPlayerMoney(source) local health = getElementHealth(source) local dimension = getElementDimension(source) local interior = getElementInterior(source) --Use dbQuery instead of _Exec local sendInfo = exports.mysql:_Query("UPDATE characters SET x=?, y=?, z=?, money=?, health=?, dimension=?, interior=?, WHERE cuenta=?", x, y, z, money, health, dimension, interior, playerAccount) if (sendInfo) then iprint("Data saved") else iprint("Error saving") end end addEventHandler("onPlayerQuit", getRootElement(), recordarData) Because I noticed the table get info but from the previus function: And not from the "uptade" one function datosAgregar(player, nombre, sexo, edadPJ2, nacionalidadPJ2) local account = getPlayerAccount(source) local accname = getAccountName(account) local cuenta = tostring(consulta) setPlayerMoney(source, 9000) setPlayerName(source, tostring(nombre)) local x, y, z = getElementPosition(source) local money = getPlayerMoney(source) local health = getElementHealth(source) local dimension = getElementDimension(source) local interior = getElementInterior(source) local addCharacter = exports.mysql:_Exec("insert into characters (name, gender, age, nation, cuenta, x, y, z, money, health, dimension, interior) values (?,?,?,?,?,?,?,?,?,?,?,?)", nombre, sexo, edadPJ2, nacionalidadPJ2, accname, x, y, z, money, health, dimension, interior) if (addCharacter) then iprint(" data saved ")
  3. I think It worked, but how I could set the player position if I put x, y, z as separated parameters in the table and I want to callback the position? This is what I made and didn't work setElementPosition(source, column["x"], column["y"], column["z"])
  4. This is the code in "mysql" resource, I followed a tutorial, so I don't know if this works for something like this: function _Query( ... ) if connection then local query = dbQuery(connection, ... ) local result = dbPoll(query,-1) return result else return false end end function _QuerySingle(str, ...) if connection then local result = _Query(str, ...) if type(result) == 'table' then return result[1] end else return false end end I get it what you did, but now...how I could call the data from that table later? and set all the parameters that I put in it? something like this: function setData() local playerAccount = getPlayerAccount(source) -- if(playerAccount) then if(isGuestAccount(playerAccount)) then return end end local setData = exports.mysql:_Query( ? ) setElementHealth = blabla setPlayerMoney = blabla2
  5. I've been trying to save the position of the player's character and it saves... but in a new table, not in the main one where its the account's name, the character's name and the rest. -> This is what happens<- This is the code I'm using for the "character money, position, and health" // i translated some concepts to english so you can understand easly what I'm trying to make: (server-side) function saveDataCharacter() local x, y, z = getElementPosition(source) local money = getPlayerMoney(source) local health = getElementHealth(source) local sendInfo = exports.mysql:_Exec("INSERT INTO characters (x,y,z, money, health) VALUES (?,?,?,?,?)", x, y, z, money, health) if (sendInfo) then iprint("Data saved") else iprint("Error saving") end end end addEventHandler("onPlayerQuit", getRootElement(), saveDataCharacter)
  6. Uptade: I solved it by my own, but now I want to transfer the information from a table to another one, how could it be possible? I know i have to use dbquery but I can't figore out how to call the data from one side to the other side... (I want to save the account registered name as the owner of the character)
  7. I saw tutorials how to use a database for players, so I tried to save the player's character (Not only the account, I want to create a RP server) and this is what I see in PhpMyAdmin -> click This is the code i'm trying to make it work: function datosAgregar(thePlayer, nombre, sexo, edadPJ2) local addCharacter = exports.mysql:_Exec("insert into characters (name, gender, age) values (?,?,?)", nombre, sexo, edadPJ2) if (addCharacter) then iprint(" data saved ") else iprint(" error ") end end addEvent("datosAgregar", true) addEventHandler("datosAgregar", getRootElement(), datosAgregar) And the console prints me "data saved" with no error... This is the code that calls the event: addEventHandler("onClientGUIClick", btnContinuar, function() local nombre = guiGetText(name) local sexo = guiRadioButtonGetSelected(gender) local edadPJ = guiComboBoxGetSelected(edades) local edadPJ2 = guiComboBoxGetItemText(edades, edadPJ) if (edadPJ2=="") then outputChatBox("---", 255, 0, 0) else triggerServerEvent("datosAgregar", getLocalPlayer(), getLocalPlayer(), nombre, sexo, edadPJ2) guiSetVisible(ventanaPanelPJ, false) end end, false) What I'm doing wrong? Also, here is the parameters I'm using for the table in PhpMyAdmin: click me
  8. I've been working on a login system lately, and I want to ask, wich is the best way to save the data from the player? All the code from my resource it's using "getAccountData" and "setAccountData", so I didn't use SQL. My problem is that, I should've asked before starting, because I suppose the process from "saving in MTA default DB", to "SQL DB" it's complicated... is it possible to start transfering the data to a custom SQL in that case? if the answers is positive, I should use SQLite or MySQL? (Example of what I mean with "saving in Default MTA DB") function logHRP(user, password) cuenta = getAccount(user, password)
  9. Solved by my own, no need for more answers thank you anyway Burak!
  10. I asked because I put the code, obviusly I tried to figure out how to make the "text" detect the combobox, but I didn't realize how. The code itself works, but I don't get how to make the "text" part get the player combobox item selected, because the "text" variable keeps with empty text
  11. But how I could add it to the guiComboBoxGeItemText thing? ?
  12. I made a button for a GUI, when the player presses it, the button triggers another GUI Panel, but I want to make sure the player complete all the comboBox items, how I could do it? A1 = guiComboBoxGetSelected(blabla) A2 = guiComboBoxGeItemText(A1) B1 = guiComboBoxGetSelected(blabla2) B2 = guiComboBoxGeItemText(B1) if (A2=="") or (B2=="") then --This doesn't work correctly, it only makes nothing happens after pressing the GUI button outputChatBox("You must... blablabla", 255, 0, 0, source) else triggerServerEvent("AwesomeFunction", getLocalPlayer(), A2, B2) end end, false) This is client side
  13. I know I asked something like this before in this topic but now I'm confused, I wanted to create an Inventory system, so i searched info, sadly, the only tutorial that I found about it (using SQL), it's a type of inventory I don't really like. My idea was making a inventory with a gui, get the player objets (like weapons) and showing the data in the gui panel with a text, I don't know if this is possible, but it's how I want to it looks like. I'm not trying to make new objets wich the player can give to other players like food, I want to create an inventory that would save the weapons, and other parameters that the player CAN'T give to other players. Example if this is possible wich commands I can use ? example of what I'm talking about: function lalala() player = getPlayerAccount(source) weapon = getPedWeapons(source) textgui = your weapon is ..weapon end addEventHandler("onResourceStart", root, lalala) ------------ then guiSetText( myLabel, textgui ) Sorry for my bad english
  14. Didn't work, I found the error, the thing is that the command is in server side, so all the conditionals I added are in the SERVER, every player can start the function. Isn't there any way to make that just a specific player can make the function to work? This is a Respawn system, so I'm needing that just the player who types the command can make it run: function revivir1() revivir = 1 ------ 1 cancelText = nil ---------2 setPedAnimation(source, ".", ".", -1, false, false, false, true) outputChatBox (".", source, 255, 0, 0) setTimer(function(source) si = 1 ------------- 3 cancelText = cancelText if (cancelText==nil) then outputChatBox(".", source, 255, 0, 0) end end, 600, 1, source) end addEvent("sistemarev", true) addEventHandler("sistemarev", root, revivir1) And then: function morir (source) if not(revivir==1) then -------------conditional cancelText = 1 spawnPlayer(source, 2041.3568115234,-1409.2247314453,17.1640625,178) si = 0 takePlayerMoney(source, 1000) takeAllWeapons(source) outputChatBox("", source, 0, 255, 0) end end addEvent("morir", true) addEventHandler("morir", root, morir) PD: Checking his(her health doesn't work for me because I made a "knoc down" function that sets the player life back in 100
  15. Similar problem is here, but this time the command works for every player intead of the source player, how could I fix this? function revivir(source) if (si==1) and (cancelText==nil) then spawnPlayer(source, 2041.3568115234,-1409.2247314453,17.1640625,178) si = 0 takePlayerMoney(source, 1000) takeAllWeapons(source) outputChatBox("...", source, 0, 255, 0) end end addCommandHandler("test", revivir)
  16. I finished a script for respawn a couple hours ago. I tested it and I found an error, the second text should appear only for the player that it's dead, but it shows up to everybody. I've been trying figuring out why this "source" works in the function for other elements like "set animation", and the firts outputChat but I stilll don't know what happened... function revivir1() revivir = 1 cancelText = nil setPedAnimation(source, ".", ".", -1, false, false, false, true) outputChatBox (".", source, 255, 0, 0) setTimer(function () si = 1 cancelText = cancelText if (cancelText==nil) then outputChatBox(".", source, 255, 0, 0) ------This is the wrong text end end, 600, 1) end addEvent("sistemarev", true) addEventHandler("sistemarev", root, revivir1) As the title says, server-side part
  17. This is server-side function... I don't know really how to make it work function hms(x,y,z) ----------------- I don't know how or where to add the "getLatentEventStatus", in the wiki the only example it's about "starts a latent event and outputs the status of the transfer to the client console" triggerLatentClientEvent("mirarA", 104857600, false, client, x,y,z) end addEvent('mirarPS', true) addEventHandler('mirarPS', root, hmc)
  18. All I got it's a "Expected number, got non-convertible string" when I added getLatentEventStatus, I don't know if I really could understand how to use it, specially because the language (english not my main language) add difficulty in this to me, because of some terms... but it still necessary add that option If I DON'T increase the bandwidth to max? or there is a chance that it will lag anyway
  19. Do you mean using that in Client-side or something else? also, how I could check if is it work? debug-script doesn't send me anything but I'm not sure if this works
  20. I was trying to learn how to make the player's head follow the cursor (and the others players can see it) and I found the "triggerLatentClientEvent " in the wiki. All it's solved but I want to ask, what's the recommended number for bandwidth? Because the number that I put it's too slow, the cursor moves and the player's head follow it seconds later, but I'm not sure to increase the number, is it gonna be laggy for other players or something like that if I increase the bandwidth? triggerLatentClientEvent("mirarjugador", 5000, false, client, x,y,z)
  21. I want the bindkey stops the animations I'm going to add function prueba(thePlayer) setPedAnimation(thePlayer, "finale", "fin_let_go", -1, false, false, false, false) end addCommandHandler("prueba", prueba) function pararAnim(thePlayer, key, keyState) setPedAnimation(thePlayer) end bindKey( thePlayer, "space", "down", pararAnim )
  22. I don't know what I'm missing, the console keeps sending to me a "[Expected player at argument 1, got nil" (bindkey part) function pararAnim(thePlayer, key, keyState) setPedAnimation(thePlayer) end bindKey( thePlayer, "space", "down", pararAnim ) server side
×
×
  • Create New...