Search the Community
Showing results for tags 'boolean'.
-
I made this: -- All other functions and GUI creation. -- [...] -- Created button called "fbumper". local function setFBumper() local theVeh7 = getPedOccupiedVehicle(localPlayer) if theVeh7 then setVehicleComponentVisible(theVeh7, "bump_front_dummy", false) end end addEventHandler("onClientGUIClick", fbumper, setFBumper, false) -- Everything else... It works. Then I wanted to have the button switch between true to false when clicked. Something like: local function setFBumper() local theVeh7 = getPedOccupiedVehicle(localPlayer) if theVeh7 then setVehicleComponentVisible(theVeh7, "bump_front_dummy", false) elseif getVehicleComponentVisible(theVeh7) == "false" then setVehicleComponentVisible(theVeh7, "bump_front_dummy", true) end end addEventHandler("onClientGUIClick", fbumper, setFBumper, false) guiSetVisible (vehmod, false) It doesn't work correctly. It sets it invisible, but it doesn't return the state to visible. I also thought about using the setVehicleComponentVisible (not setVehicleComponentVisible) to make it a little bit more compact. I'm using a setEngineState script to help myself, but I don't know how to use it with these arguments. DB 3 throws nothing. What am I doing wrong?
-
The connection is okay but dbQuery and dbPoll first argument got nil. ( sorry for my bad english ) ERROR: MYSQL CONNECTION CODE: "felhasznalo" SCRIPT:
- 9 replies
-
- mta
- connection
-
(and 7 more)
Tagged with:
-
(sry for my bad english) Hi everyone! In my script when I write the command into game chatbox (/makeveh "myID" "CarModelName" "Faction" "R, G, B") i get this Error message to server console: ERROR: mta_vehicle\sourceS.lua:263: attempt to compare boolean with number. The code is: addCommandHandler("makeveh", function(player, _, ownerID, modelID, faction, r, g, b) if getElementData(player, "acc:admin") >= 7 then <--LINE 263 if not modelID or not tonumber(ownerID) then outputChatBox(rovid .. " /makeveh [Név/ID] [Model] [Frakció] [R] [G] ", player, 0, 0, 0, true) return end target, targetName = exports.mta_main:findPlayer(player, ownerID) if not target then return else ownerID = getElementData(target, "char:id") end if not tonumber(faction) then faction = 0 end if not tonumber(r) then r = 0 end if not tonumber(g) then g = 0 end if not tonumber(b) then b = 0 end r = tonumber(r) g = tonumber(g) b = tonumber(b) local vehname = tonumber(modelID) if not vehname then vehname = getVehicleModelFromName(modelID) end if not vehname then outputChatBox(rovid .. " Hibás jármű név vagy id", player, 0, 0, 0, true) return end local x, y, z = getElementPosition(target) local insertQuery = dbQuery(con, "INSERT INTO vehicle SET model=?, owner=?, pos=?, color=?, faction=?, rendszam=?", vehname, ownerID, toJSON({x,y,z}), toJSON({r,g,b}), faction, "modify") local insertResult, _, insertID = dbPoll(insertQuery, -1) if insertResult then addVehicle(ownerID, vehname, x, y, z, insertID, r, g, b, faction) exports.mta_item:giveItem(target, 34, insertID, 1, 0) exports.mta_admin:outputDeveloperMessage("#7cc576"..player:getData("char:anick").." #fffffflétrehozott egy járművet (ID: "..insertID.." Tulaj: "..targetName:gsub("_", " ")..")") dbFree(insertQuery) end end end)
-
Hola ando necesitando ayuda con un script, el mismo es el de la clasica Killcam (https://community.multitheftauto.com/index.php?p=resources&s=details&id=5362) pero le quise agregar una seguridad para cuando el jugador que recibe el disparo (Reciever) se desconecte, el mismo sea baneado. Pero no logro hacerlo, he hecho esto: Client (completo con mi codigo): function movecamera() x, y, z = getElementPosition(camobj) th, tj, tk = getElementPosition(tarobj) setCameraMatrix(x, y, z, th, tj, tk) end function shotfunc() if alpha <= 255 and alpha > 0 then alpha = alpha - 1 dxDrawText(text, 576, 544, 778, 601, tocolor(255, 200, 0, alpha), 2, "sans", "center", "top", false, false, false) end end addEventHandler("onClientRender", root, shotfunc) text = " " alpha = 0 function goodguy1() dxDrawLine3D(th, tj, tk, th + (hx - th - (hx - th + 0.2)), tj + (hy - tj - (hy - tj + 0.2)), tk + (hz - tk - (hz - tk + 0.2)), tocolor(64, 64, 64, 255)) end function goodguy2() dxDrawLine3D(tv, tb, tn, tv + (hx - tv - (hx - tv + 0.2)), tb + (hy - tb - (hy - tb + 0.2)), tn + (hz - tn - (hz - tn + 0.2)), tocolor(64, 64, 64, 255)) end function movereciever() tv, tb, tn = getElementPosition(target) h, j, k = getElementPosition(localPlayer) setCameraMatrix(h + 5, j + 5, k + 5, tv, tb, tn) end function killcam(tz, tx, tc, hjx, hjy, hjz, bodypart, moving, reciever, weapon) addEventHandler ( "OnClientChatMessage", getRootElement(), function() cancelEvent() end ) addEventHandler ( "OnClientConsole", getRootElement(), function() cancelEvent() end ) setGameSpeed(0.05) camobj = createObject(327, tz + 2.5, tx + 2.5, tc + 2.5) tarobj = createObject(327, tz, tx, tc) setElementData(localPlayer,"killca",true) setElementAlpha(camobj, 0) setElementAlpha(tarobj, 0) moveObject(camobj, 4000, hjx + 5, hjy + 5, hjz + 5) if bodypart == 9 then moveObject(tarobj, 5000, hjx, hjy, hjz + 1) else moveObject(tarobj, 5000, hjx, hjy, hjz) end hx = hjx hy = hjy hz = hjz addEventHandler("onClientRender", root, movecamera) addEventHandler("onClientRender", root, goodguy1) addEventHandler("onClientPlayerQuit", reciever, function () if getElementData(reciever,"killca") == true then playerToBan = getPlayerName(reciever) triggerServerEvent("banPlayer", getLocalPlayer(), playerToBan) end end) function killz() triggerServerEvent("onKillCamFinish", root, localPlayer, reciever, weapon) fxAddBlood(hjx, hjy, hjz, 0, 0, 0, 5, 1) setElementData(localPlayer,"killca",true) removeEventHandler("onClientRender", root, goodguy1) setGameSpeed(0.2) end setTimer(killz, 5000, 1) if bodypart == 3 then if moving then text = "KILL EN MOVIMIENTO" else text = "KILL" end elseif bodypart == 4 then if moving then text = "Kill en movimiento! ¡Le diste en los testiculos a "..getPlayerName(reciever):gsub("#%x%x%x%x%x%x", "").."" else text = "¡Le diste en los testiculos a "..getPlayerName(reciever):gsub("#%x%x%x%x%x%x", "").."!" end elseif bodypart == 9 then if moving then text = "HEADSHOT en movimiento a "..getPlayerName(reciever):gsub("#%x%x%x%x%x%x", "") else text = "HEADSHOT a "..getPlayerName(reciever):gsub("#%x%x%x%x%x%x", "") end end function setnormalcam() removeEventHandler("onClientRender", root, movecamera) setCameraTarget(localPlayer) destroyElement(camobj) setGameSpeed(1.2) setElementData(localPlayer,"killca",false) alpha = 255 end setTimer(setnormalcam, 6000, 1) end addEvent("onSniperHeadshot", true) addEventHandler("onSniperHeadshot", root, killcam) function recievehs(shx, shy, shz, hitx, hity, hitz) setGameSpeed(0.05) setElementData(localPlayer,"killca",true) target = createObject(327, shx, shy, shz) setElementAlpha(target, 0) moveObject(target, 5000, hitx, hity, hitz) hx = hitx hy = hity hz = hitz addEventHandler("onClientRender", root, movereciever) addEventHandler("onClientRender", root, goodguy2) function gods() removeEventHandler("onClientRender", root, goodguy2) setGameSpeed(0.2) setElementData(localPlayer,"killca",true) end setTimer(gods, 5000, 1) function endcam() removeEventHandler("onClientRender", root, movereciever) destroyElement(target) setCameraTarget(localPlayer) setGameSpeed(1.2) setElementData(localPlayer,"killca",false) end setTimer(endcam, 6000, 1) end addEvent("onRecieveSniperHeadshot", true) addEventHandler("onRecieveSniperHeadshot", root, recievehs) function bloodhead(weapon, ammo, ammoclip, hx, hy, hz, hitelement, sx, sy, sz) if weapon == 34 then a = hx s = hy d = hz function bloods() fxAddBlood(a, s, d, 0, 0, 0, 5, 1) end setTimer(fxAddBlood, 3500, 1) end end addEventHandler("onClientWeaponFire", root, bloodhead) function godci () if getElementData(localPlayer,"killca") == true then cancelEvent() end end addEventHandler("onClientPlayerDamage",root,godci) Aqui solo el codigo que agregue yo para que entiendan mejor y no tengan que buscar: addEventHandler("onClientPlayerQuit", reciever, function () if getElementData(reciever,"killca") == true then playerToBan = getPlayerName(reciever) triggerServerEvent("banPlayer", getLocalPlayer(), playerToBan) end end) Server: function banPlr(who) local targetPlayer = getPlayerFromName ( who ) banPlayer(targetPlayer,false,false,true,root,"Salir de Killcam",14400) outputChatBox ( "#FE2E2E[LPM.KCProtection] "..who.."#FE2E2E ha sido baneado por salir de Killcam (4 horas).", root, 255, 0, 0, true ) outputDebugString ("Jugador "..who.." baneado correctamente por salir de Killcam.") end addEvent("banPlayer", true) addEventHandler("banPlayer", getRootElement(), banPlr) El otro server esta compilado por eso no lo agrego, pero la killcam funciona. El problema esta en el getPlayerFromName, cuando quiero banear al jugador dice que espera recibir el Player, pero recibe un boolean y no se por que, si yo le estoy pasando el string correctamente (ya que en el ChatBox y el DebugString se imprimen correctamente). Espero puedan ayudarme, muchas gracias