Jump to content

Cronoss

Members
  • Posts

    173
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by Cronoss

  1. I also had this problem but it was because of the name of my function... but not always it's because of that, in this "error", the function it's calling itself without finishing the initial execution, so the problem could be in another part of the code. You should post the rest of it, so people of the community can help you easily, sometimes the console sends me the line where "the error is" and I find the problem 2 lines above, so...
  2. 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
  3. Hello, this is a quick question (I guess), first of all, I started making this script because the previous one that I used (free script avaible in "resources") was too "hard" to understand for me, so I decided starting my own script, that way I learn and I know how my script works at the same time, (so this is NOT a repost, just in case). Now, my problem, I made a toggle engine function, it works perfectly, BUT I'm not sure if this is the right way... I'm using the "plate" of the vehicle as a "key", so the player that doesn't have the same plate text of the vehicle he is in, CAN'T toggle engine: function toggleEngine(thePlayer, cmd) local vehicle = getPedOccupiedVehicle(thePlayer) local identify = getVehiclePlateText(vehicle) local owner = getPlayerName(thePlayer) local check = exports.mysql:_Query("SELECT * FROM vehicles WHERE owner=?", owner) ---Gets the info of the player inside the vehicle (plate and engine) if (check) then if(#check > 0) then -----------else, doesn't allow the player toggle for _,column in ipairs(check) do vehicleOwned = tostring(column["plate"]) ----------Gets the plate enginestate = tonumber(column["engine"]) if (identify==vehicleOwned) then -------compares the plate of the vehicle, if it's the same, allows to toggle engine, if not, the player can't if (enginestate==1) then setVehicleEngineState(vehicle, false) enginestate = 0 iprint("B1") elseif(enginestate==0) then setVehicleEngineState(vehicle, true) enginestate = 1 iprint("B2") end local sendinfo = exports.mysql:_Query("UPDATE vehicles SET motor=? WHERE owner=?", enginestate, owner) ----sends the info ------blablabla Now, if this works perfectly as I say why I consider it's not the right way? Because I realized that the player who buys more than 1 car would generate a bug inside this function, because the plates would be the same, but at same time not the same (?) I tested it with a friend and this happened, it spams the "you don't have the keys" message ^^^^ I don't need a code, just asking if there is a better way to detect this kind of stuff, thanks for reading
  4. 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
  5. My bad, I was trying to make a function for every marker, it caused a lot of problems, this is better than the 200 lines of code that I made, thank you!
  6. I'm making a marker-system, when the player hit the marker it deletes the current one, and creates a new one, the problem is that debugscript send me "expected element at argument 2, got nil", if I use "root" or "getRootElement()" in that part, it works but FOR EVERY other marker, so it's kinda chaotic... (I'm scripting this in CLIENT-SIDE, because I only want the player who used the command can see the markers, not everybody) I used: ------------------------Initial marker--------------------- function startGH() ---------outputChatBox mark1 = createMarker(1888.5596923828,-2055.2121582031,13.3828125, "checkpoint", 1, 90, 255, 20) ------This is the first marker end addEvent("gah", true) addEventHandler("gah", root, startGH) --------------------------Marker Delete---------------- function markDelete(hitPlayer) iprint("1") if getElementType( hitPlayer ) == "player" and source == mark1 then destroyElement(mark1) local vehicle = getPedOccupiedVehicle(hitPlayer) setElementFrozen(vehicle, true) -------outputChatBox setTimer(function () -------outputChatBox setElementFrozen(vehicle, false) mark2 = createMarker() ---unnecessary info, second marker end, 5000, 1) end end end addEventHandler("onClientMarkerHit", mark1, markDelete) ------got nil Also, I tried using "onMarkerHit" but didn't work, so "onClientMarkerHit" it's the only way that I know that could make possible my system Maybe there's a better way to make a system like this but I don't know how, I tried using a table but it didn't work
  7. Hello again, this time I'm not posting because of an error of my script or something like that, I want to ask if is it possible to execute an animation while the player walks or moves without cancelling the "walk", I mean, when you set the player's animation they freeze, and I tried turning "true" some parameters but it's not working for me. function blablabla(thePlayer) setPedAnimation(thePlayer, "animation", "animation", -1, false, true, true, false) ------parameters ---------blablabla If exist something that could make possible run the animation while the player walks or moves... I would like to know how and why the other parameters doesn't allow me to make that possible
  8. I just found that I can "restrict" the spam of a command with "onPlayerCommand", I tested it and it works, it doesn't allow the command to execute if the player doesn't wait 2 seconds, there is any difference between this and that table example?
  9. Hello, this is my problem: I made a cigarette system for my server but I've been testing it and I found only 1 problem, when the player "spams" the command "/smoke" the part where the object it's deleted doesn't work corectly and DO NOT delete the object. How could I solve this? The part where the system deletes the object: setPedAnimation(thePlayer, "-", "-",false,false,false,false) local cancelsmoke = setTimer(function() exports.pAttach:detach(smoking,thePlayer) destroyElement(smoking) iprint("Destroyed") end, 2500, 1) If the player puts the command it works, the bug only happens when the player spam the command
  10. I used a previous command for the new "bone attach" resource, just in case this happens to another person, check the new parameters if you downloaded it
  11. local x,y,z = getElementPosition(thePlayer) cigarro = createObject(3044, x, y, z) exports.bone_attach:attachElementToBone(cigarro, thePlayer, 12, 0, 0, 0, 0, 0, 0) Debug script says "ERROR: blablabla exports: Call to non-running server resource (bone_attach) [string "?"], don't know what it means really
  12. The column in the table was specified with "INT" instead of "VARCHAR", thank you for your help Burak! it's a little confusing to me... Why sometimes it's VARCHAR and sometimes "INT" ? my columns with INT: Position, dimension, interior, rotation... my columns with VARCHAR: names, texts, name of the account... but why this (weapon's table) have to be varchar? just asking EDIT: I know int means integer, but why in this case the int doesn't work?
  13. Well, the console sent me the error in this part: for weapon, ammo in pairs(fromJSON(weapons)) do Something like "the table doesn't exist"... that's why I thought I made it wrong. But i don't know if it would work with that part fixed, because, as i said, the table doesn't get any info in the weapon column, it keeps empty ----- And, my answers for your questions: 1.- Yes, empty all the time 2.- I'll be checking that later, because now I'm leaving my house 3.- Yes, the "giveWeaponsFromJSON(source, column["weapon"])" it's after the spawn and all that stuff for the player, here it's the full code: function cargarDatos() local playerAccount = getPlayerAccount(source) if(playerAccount) then if(isGuestAccount(playerAccount)) then return end end local accName = getAccountName(playerAccount) local setData = exports.mysql:_Query("SELECT * FROM characters WHERE cuenta=? LIMIT 1", accName) if (setData) then if(#setData > 0) then for _,column in ipairs(setData) do setPlayerMoney(source, column["money"]) setPlayerName(source, column["name"]) setCameraTarget(source) showCursor(source, false) spawnPlayer(source, column["x"], column["y"], column["z"]) ---------spawn setElementDimension(source, column["dimension"]) setElementInterior(source, column["interior"]) setElementRotation(source, column["xr"], column["yr"], column["zr"]) setElementModel(source, column["skin"]) setElementHealth(source, column["health"]) giveWeaponsFromJSON(source, column["weapon"]) ---------------Weapons break end end end end
  14. I think i'm misunderstanding what you telling me to do... I tried something but i'm doing it wrong: function recordarData() local playerAccount = getPlayerAccount(source) if(playerAccount) then end local x, y, z = getElementPosition(source) local money = getPlayerMoney(source) local health = getElementHealth(source) local dimension = getElementDimension(source) local interior = getElementInterior(source) local skin = getElementModel(source) local account = getAccountName(playerAccount) local xr, yr, zr = getElementRotation(source) local weapon = convertWeaponsToJSON(source) ---------here local sendInfo = exports.mysql:_Query("UPDATE characters SET x=?, y=?, z=?, money=?, health=?, dimension=?, interior=?, skin=?, xr=?, yr=?, zr=?, weapon=? WHERE account=?", x, y, z, money, health, dimension, interior,skin,xr,yr,zr,weapon, account) -----send the weapon info if (sendInfo) then iprint("Data saved") ------this shows up in the console else iprint("Error saving") end end addEventHandler("onPlayerQuit", getRootElement(), recordarData) I created "weapon" in the character's table so It should save the info from the function and send it to phpmyadmin but I just checked and nothing happens When player login: giveWeaponsFromJSON(source, column["weapon"]) -----this is just the weapon part If i'm doing it in the wrong way I apologize for making the message too long note: I obviusly added the function "giveweaponsfromjson" and the other one, so that's not the problem
  15. function giveMoney(cmd) if (moneyChances == nil) then ------if moneyChances == nil | moneyChances doesn't appear before in the function, the value it's nil givePlayerMoney(source, 50000) ------50.000 the amount of money the player get with the command. (You can edit this number) moneyChances = 1 -------moneyChances = 1, so the first variable now it's NOT nil, that should block the option of giving the money to the player else outputChatBox("You already used this command.", source, 255, 0, 0) --------if moneyChances == 1 then this text shows up end end addCommandHandler("money", giveMoney) (server-side) PD: Not tested, but this could give you an idea on how to make it, I hope it help you note: I'm new trying to help in this section, if I'm wrong or I missed something please tell me and I'll learn about my mistake
  16. Primero que nada, esta es la sección de scripts en inglés, por lo que si vas a comentar o preguntar por acá traduce tu texto al inglés o si tienes algo de conocimiento del idioma conviértelo tú para que tenga cierta lógica, segundo, para encontrar el "script" que dices buscar, creo que más bien te refieres a un resource, hay de esos gratis en el siguiente enlace -> click Más que eso no sabría en qué más ayudarte, aunque no te recomendaría buscar resources con script ya hecho, porque al final poco aprendes y si tu intención es abrir un servidor hacía una comunidad o publico, no es recomendado crear el servidor en base a otros scripts y mecanismos que no sabes como funcionan, por eso te recomiendo aprender un poco de lua y sobre sql, he de admitir que soy un completo novato en esto todavía, pero trato de aprender lo más que puedo en esta sección del foro, cuando hagas tus preguntas sobre cierto código no esperes el código listo, trata de recibir una explicación de porque tu script no sirve y como podrías solucionarlo.
  17. I can't find any tutorial about something like this but I know it's possible because I searched if this question was made before in the forum and yes, I saw some codes and explanation from users and mods, but it doesn't work for me, because I'm using mysql and phpmyadmin, the examples doesn't match with my project, so I was wondering if someone could help me to understand how to save the data from the player's weapon and ammo... this is what I tried first: ---------this is inside of a function that saves all the player's info-------- local weapon1 = getPedWeapon (source) local weapon = getWeaponNameFromID (weapon) local ammo = getPedTotalAmmo(source) --------the info it's send to the table (this was simplified)----------- local sendInfo = exports.mysql:_Query("UPDATE characters SET weapon=?, ammo=? WHERE account=?", weapon, ammo, account) Since i've started, many problems as "getPedWeapons a nill value" appeared in the console, also "expected number, got boolean", etc. If there is a way to make a system like this without the getaccountdata/setaccountdata... I would like to know how to make it. I'm not asking for a full code, just some of knowlegde
  18. I didn't change it but I added tickcount and it worked, thank you anyway
  19. Well, it's too late to delete it, so if a mod or admin see this, please delete this or move it, I solved the problem
  20. Basically I wanted to create an script that could make possible choose a random song from the table "songs". The problem is that the math.random always choose the same song, I don't know what it's happening; (client-side) --------------Table------------------------- local songs = {"a.mp3", "b.mp3", "c.mp3"} ---------------This part chooses randomly the song play = songs[math.random(#songs)] song = playSound(play, true)
  21. Damn, didn't notice until now, thank you didn't notice until now
  22. Well, I'm trying to make an Event from Server-Side to Client-Side so the camera of the player fade in black and backs to normal when the event it's called, but for some reason I got this new error that I never saw before, "stack overflow", I searched and It's a problem that happens when you accidentaly make a infinite loop, but what's wrong with this?? function fadeCamera() fadeCamera(source, true, 0.5, 0, 0, 0) setTimer(function() fadeCamera(source, false) end, 1500, 1, source) end addEvent("camaraFade", true) addEventHandler("camaraFade",getRootElement(), fadeCamera)
  23. That was the problem, thank you Burak. And also... what's the difference between making the connection like this way: exports.mysql:_Query("INSERT blablablalba") And this way: dbQuery(connection, "INSERT blabla") I'm just asking because I don't know if I'm using correctly the function
×
×
  • Create New...