Jump to content

SaNoR

Members
  • Posts

    45
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by SaNoR

  1. addEventHandler("onPlayerDamage", root, function(attacker, weapon, part) if part == 9 and isElement(attacker) and attacker ~= source then killPed(source, attacker, weapon, part) end end)
  2. Maybe this will help debugSleep
  3. addEventHandler("onPlayerJoin", root, function() local ip = getPlayerIP(source) local function displayPlayerCity(resp, errno, source) if errno == 0 then local data = fromJSON("[".. resp .. "]") local status = data["status"] or "fail" if status == "success" then if isElement(source) then outputChatBox(getPlayerName(source).." has joined the game ("..data["city"]..", "..data["country"]..")", root, 255, 100, 100) end else if isElement(source) then outputChatBox(getPlayerName(source).." has joined the game.", root, 255, 100, 100) end outputDebugString("JOINQUIT: Cannot retrieve network details") end else outputDebugString("JOINQUIT: Error @fetchRemote, ERRNO: "..errno) end end fetchRemote("http://ip-api.com/json/" .. ip, displayPlayerCity, "", false, source) end, true, "low")
  4. Don't be toxic, retard. I was talking about https://imgur.com/D76s3Rm
  5. It's sometimes happens when u copy code from forum, just write this line by yourself.
  6. Something like this function getPlayerFromPartialName(name) local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil if name then for _, player in ipairs(getElementsByType("player")) do local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() if name_:find(name, 1, true) then return player end end end end function aBan(source, cmd, nickname, time, ...) if (hasObjectPermissionTo(source, "function.banPlayer", false)) then time = tonumber(time) if nickname and time then local b_player, b_serial, b_time, b_reason = getPlayerFromPartialName(nickname), "", 1, "" if isElement(b_player) then b_serial = getPlayerSerial(b_player) b_time = getRealTime().timestamp + (time * 86400) if #{...} ~= 0 then b_reason = table.concat({...}, " ") end if kickPlayer(b_player, source, b_reason) then -- INSERT TO MYSQL b_serial, b_time, b_reason outputChatBox(getPlayerName(b_player).." has been banned by "..getPlayerName(source)..". ("..time.." day"..(time == 1 and ")" or "s)"), root, 255, 0, 0) end end else outputChatBox("/aban [Nickname] [Days] [Reason]", source, 255, 0, 0) end end end addCommandHandler("aban", aBan) addEventHandler("onPlayerJoin", root, function() local serial = getPlayerSerial(source) -- SELECT PLAYER SERIAL FROM DB if #result ~= 0 then -- IF FOUND if getRealTime().timestamp < result.b_time then kickPlayer(source, os.date("%Y-%m-%d %H:%M:%S", result.b_time)) end end end)
  7. function showAmmoGUI(hitPlayer) triggerClientEvent(hitPlayer, "showAmmoGUI_Ed", getRootElement(), hitPlayer, marker) end addEventHandler("onPlayerPickupHit", marker, function() bindKey(source, "N", "down", showAmmoGUI) end) addEventHandler("onPlayerPickupLeave", marker, function() unbindKey(source, "N", "down", showAmmoGUI) end)
  8. SaNoR

    wanted level

    -- player's screen size width * (icon size / you'r screen size width) -- same with height local sw, sh = guiGetScreenSize() local mineX, mineY = 1280, 720 -- you'r current screen resolution (from video setting) local icon_width, icon_height = sw * (20 / mineX), sh * (20 / mineY) -- star.png width, height local space = sw * (1 / mineX) -- space between icons local x, y = sw - icon_width - sw * (50 / mineX), sh * 0.5 -- x, y position
  9. Use a multiline string. win.text = [[ 1st: Nickname 123 2nd: Nickname 13123 3nd: Nickname 141523 ]]
  10. SaNoR

    wanted level

    local sw, sh = guiGetScreenSize() local icon_width, icon_height = 20, 20 -- star.png width, height local space = 1 -- space between icons local x, y = sw - icon_width - 50, sh * 0.5 -- x, y position addEventHandler("onClientRender", root, function() for i = 1, getPlayerWantedLevel() do dxDrawImage(x + (icon_width + space) - i * (icon_width + space), y, icon_width, icon_height, "star.png") end end)
  11. Use loop As example: function updateScoreboard() scoreboard = {} for _, player in ipairs(getElementsByType("player")) do if not getPlayerTeam(player) then for n = 1, 10 do table.insert(scoreboard, {"player", player}) end end end
  12. https://wiki.multitheftauto.com/wiki/Scripting_Introduction#Clientside_and_Serverside_scripts
  13. SaNoR

    Dx Visibility

    function Dx () if getPlayerTeam(localPlayer) == getTeamFromName("Admins") then dxDrawText("text", 1, 1, 1, 1, tocolor(250, 120, 4, 255), 7.00, "bankgothic", "center", "center", false, false, false, false, false) end end
  14. dxDrawText( un:O(killRow[r]["killerName"]), killRow[r]["killerNamePos"]["leftX"] + 1, killRow[r]["killerNamePos"]["topY"] + 1, killRow[r]["killerNamePos"]["rightX"] + 1, killRow[r]["killerNamePos"]["bottomY"] + 1, label_shadowColor, 1, label_font, "right", _, _, _, _, true) dxDrawText( killRow[r]["killerName"], killRow[r]["killerNamePos"]["leftX"], killRow[r]["killerNamePos"]["topY"], killRow[r]["killerNamePos"]["rightX"], killRow[r]["killerNamePos"]["bottomY"], killRow[r]["killerNameColor"], 1, label_font, "right", _, _, _, _, true) This should help. I just forgot to do it
  15. SaNoR

    Health problem

    I test it in local server and everything works fine. Maybe you're problem in "ArMoR" event.
  16. SaNoR

    Health problem

    function armor(loss) local Health = getElementHealth(source) local Armour = getPedArmor(source) if Armour - tonumber(loss) >= 0 then setPedArmor(source, Armour - tonumber(loss)) else setPedArmor(source, 0) end if getPedArmor(source) == 0 then setElementHealth(source, Health + (Armour - tonumber(loss))) end end addEvent("ArMoR", true) addEventHandler("ArMoR", getRootElement(), armor)
  17. function renderClientKillPanel () for r = 1, rows do if killRow[r] then dxDrawText( killRow[r]["killerName"], killRow[r]["killerNamePos"]["leftX"] + 1, killRow[r]["killerNamePos"]["topY"] + 1, killRow[r]["killerNamePos"]["rightX"] + 1, killRow[r]["killerNamePos"]["bottomY"] + 1, label_shadowColor, 1, label_font, "right", "top", _, _, _, true) dxDrawText( killRow[r]["killerName"], killRow[r]["killerNamePos"]["leftX"], killRow[r]["killerNamePos"]["topY"], killRow[r]["killerNamePos"]["rightX"], killRow[r]["killerNamePos"]["bottomY"], killRow[r]["killerNameColor"], 1, label_font, "right", "top", _, _, _, true) dxDrawImage( killRow[r]["reasonIconPos"]["leftX"], killRow[r]["reasonIconPos"]["topY"], icon_width, icon_height, imagePath[ killRow[r]["deathReason"] ] ) dxDrawText( killRow[r]["victimName"], killRow[r]["victimNamePos"]["leftX"] + 1, killRow[r]["victimNamePos"]["topY"] + 1, killRow[r]["victimNamePos"]["rightX"] + 1, killRow[r]["victimNamePos"]["bottomY"] + 1, label_shadowColor, 1, label_font, "right", "top", _, _, _, true) dxDrawText( killRow[r]["victimName"], killRow[r]["victimNamePos"]["leftX"], killRow[r]["victimNamePos"]["topY"], killRow[r]["victimNamePos"]["rightX"], killRow[r]["victimNamePos"]["bottomY"], killRow[r]["victimNameColor"], 1, label_font "right", "top", _, _, _, true) end end end addEventHandler ( "onClientRender", root, renderClientKillPanel )
  18. setTimer(function() if coroutine.status (clearing_nonexisting_peds) == "dead" then clearing_nonexisting_peds = coroutine.create(forgetNonExistingPeds) end coroutine.resume(clearing_nonexisting_peds) end, 1000, 0)
  19. function Exp(user, cmd, Player, Quantity) local AccountPlayer = getAccountName(getPlayerAccount(user)) if isObjectInACLGroup("user."..AccountPlayer, aclGetGroup("Admin")) then if Player and Quantity then local Playername = getPlayerFromName(Player) if Playername then if Quantity:match("^%d+$") then local lvl = getElementData(Playername, "Level") or 1 local exp = getElementData(Playername, "Exp") or 0 local Maximumprogress = getElementData(Playername, "maximumprogress") if tonumber(exp) + tonumber(Quantity) >= Maximumprogress then setElementData(Playername, "Level", tonumber(lvl) + 1) setElementData(Playername, "Exp", 0) else setElementData(Playername, "Exp", tonumber(exp) + tonumber(Quantity)) end else outputChatBox("Quantity must be a number.", user, 255, 0, 0) end else outputChatBox("Player not found.", user, 255, 0, 0) end else outputChatBox("/exp [Player, Quantity].", user, 255, 0, 0) end else outputChatBox("You don't have rights.", user, 255, 0, 0) end end addCommandHandler("exp", Exp)
  20. https://wiki.multitheftauto.com/wiki/Introduction_to_Scripting_the_GUI#Relative_and_Absolute
  21. local sw, sh = guiGetScreenSize() local jumpTimer = 0 local reload = 3000 function jump() if getTickCount() - jumpTimer > reload then local vehicle = getPedOccupiedVehicle(localPlayer) if(vehicle)then local sx, sy, sz = getElementVelocity(vehicle) setElementVelocity(vehicle, sx, sy, sz+0.33) end jumpTimer = getTickCount() end end addEventHandler("onClientRender", root, function() local now = getTickCount() local endTime = jumpTimer + reload local elapsedTime = now - jumpTimer local duration = endTime - jumpTimer local progress = elapsedTime / duration local width = interpolateBetween(0, 0, 0, 200, 0, 0, progress, "Linear") dxDrawRectangle(sw/2 - 100, sh - 100, 200, 20, tocolor(0, 0, 0, 180)) dxDrawRectangle(sw/2 - 100, sh - 100, width, 20, tocolor(0, 255, 0, 180)) end) bindKey("lshift", "down", jump)
×
×
  • Create New...