Jump to content

SaNoR

Members
  • Posts

    45
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by SaNoR

  1. 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")

     

  2. 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)

     

  3. 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)

     

  4. 38 minutes ago, slapz0r said:

    Can you tell me how to make the star size the same for all resolutions?

    -- 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

     

    • Like 1
  5. 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)

     

    • Like 1
  6. 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

     

  7. 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

     

    • Thanks 1
  8. 3 hours ago, Pedro001 said:

    Yes it works!!! 

    The killer's name is a bit far from the icon, but I'll see if I can do it. 

    Thank you very much !!! 

    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

  9. 17 hours ago, Sendy said:

    Thanks but not work :( i have 1 health and 100 armor and when ped attack to me i'am dead.. when i have 2 and more health and armor 100 and peds attack to me its working loss

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

  10. 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)

     

  11. On 07/02/2019 at 03:33, Pedro001 said:

    It didn't work 

    Spoiler
    
    local screen_maxX,      screen_maxY =           guiGetScreenSize()
    local icon1_centerX,    icon1_topY =            0.84,                   0.3
    local icon_width,       icon_height =           24,                     24
    local icon_sideMargin,  icon_bottomMargin =     10,                     5
    local label_width,      label_height =          200,                    20
    local label_font,       label_topMargin =       "default-bold",         3
    local label_shadowColor = tocolor(12,12,12)
    local rows = 5
    
    local rows_margin =     icon_height + icon_bottomMargin
    
    local label1_leftX =    screen_maxX * icon1_centerX - icon_width/2 - icon_sideMargin - label_width
    local label1_rightX =   label1_leftX + label_width
    local label2_leftX =    label1_rightX + icon_sideMargin*2 + icon_width
    local label2_rightX =   label2_leftX + label_width
    
    local icon_leftX =      label1_rightX + icon_sideMargin
    local icon_topY =       screen_maxY * icon1_topY
    
    local root =            getRootElement()
    local resourceRoot =    getResourceRootElement()
    local killRow = {}
    
    local imagePath = {
        [0] =  "icons/weapons/fist.png",
        [1] =  "icons/weapons/brassKnuckles.png",
        [2] =  "icons/weapons/golfClub.png",
        [3] =  "icons/weapons/nightstick.png",
        [4] =  "icons/weapons/knife.png",
        [5] =  "icons/weapons/baseballBat.png",
        [6] =  "icons/weapons/shovel.png",
        [7] =  "icons/weapons/poolCue.png",
        [8] =  "icons/weapons/katana.png",
        [9] =  "icons/weapons/chainsaw.png",
        [10] = "icons/weapons/dildo.png",
        [11] = "icons/weapons/dildo.png",
        [12] = "icons/weapons/dildo.png",
        [13] = "icons/deathReasons/death.png", 
        [14] = "icons/weapons/flowers.png",
        [15] = "icons/weapons/cane.png",
        [16] = "icons/weapons/grenade.png",
        [17] = "icons/weapons/tearGas.png",
        [18] = "icons/weapons/molotovCocktail.png",
        [19] = "icons/weapons/rocketLauncher.png",
        [20] = "icons/weapons/hsRocketLauncher.png", 
        [21] = "icons/deathReasons/explosion.png", 
        [22] = "icons/weapons/9mm.png",
        [23] = "icons/weapons/silenced9mm.png",
        [24] = "icons/weapons/desertEagle.png",
        [25] = "icons/weapons/shotgun.png",
        [26] = "icons/weapons/sawnoffShotgun.png",
        [27] = "icons/weapons/combatShotgun.png",
        [28] = "icons/weapons/microSmg.png",
        [29] = "icons/weapons/mp5.png",
        [30] = "icons/weapons/ak47.png",
        [31] = "icons/weapons/m4.png",
        [32] = "icons/weapons/tec9.png",
        [33] = "icons/weapons/countryRifle.png",
        [34] = "icons/weapons/sniperRifle.png",
        [35] = "icons/weapons/rocketLauncher.png",
        [36] = "icons/weapons/hsRocketLauncher.png",
        [37] = "icons/weapons/flamethrower.png",
        [38] = "icons/weapons/minigun.png",
        [39] = "icons/weapons/satchelCharge.png",
        [40] = "icons/weapons/detonator.png", 
        [41] = "icons/weapons/spraycan.png",
        [42] = "icons/weapons/fireExtinguisher.png",
        [43] = "icons/deathReasons/explosion.png", 
        [44] = "icons/weapons/goggles.png", 
        [45] = "icons/weapons/goggles.png", 
        [46] = "icons/weapons/parachute.png", 
    
        [49] =  "icons/deathReasons/rammed.png",
        [50] =  "icons/deathReasons/helicopterBlades.png",
        [51] =  "icons/deathReasons/explosion.png",
        [52] =  "icons/deathReasons/fire.png",
        [53] =  "icons/deathReasons/death.png",
        [54] =  "icons/deathReasons/fall.png",
        [255] = "icons/deathReasons/death.png",
    
        connected =    "icons/connectStates/connected.png",
        disconnected = "icons/connectStates/disconnected.png"
    }
    
    local un = {}
    
    function un:O(text)
        return string.gsub(text, "(#%x%x%x%x%x%x)", function(colorString) return "" end)
    end
    
    
    function onClientResourceStart(resource)
    	setBlurLevel(0)
    end
    addEventHandler( "onClientResourceStart", resourceRoot, onClientResourceStart)
    
    
    function renderClientKillPanel ()
    
        for r = 1, rows do
            if killRow[r] then
    
                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,
                    _, _, _, _, _, 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,
                    _, _, _, _, _, true)
    
                dxDrawImage( killRow[r]["reasonIconPos"]["leftX"], killRow[r]["reasonIconPos"]["topY"],
                    icon_width, icon_height,
                    imagePath[ killRow[r]["deathReason"] ] )
    
                dxDrawText( un:O(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,
                    _, _, _, _, _, 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,
                    _, _, _, _, _, true)
    
            end
        end
    
    end
    addEventHandler ( "onClientRender", root, renderClientKillPanel )
    
    function showClientDeathMessage ( killerName, killerNameColor, deathReason, victimName, victimNameColor )
    
        local firstRow = killRow[1]
    
        for r = 1, rows - 1 do
            killRow[r] = killRow[r + 1]
        end
    
        if type(killerNameColor) ~= "table" then killerNameColor = {255,255,255, true} end
        if type(victimNameColor) ~= "table" then victimNameColor = {255,255,255} end
    
        if firstRow then
    
            killRow[rows] = firstRow
    
            killRow[rows]["killerName"] =       tostring(killerName)
            killRow[rows]["killerNameColor"] =  tocolor( unpack(killerNameColor) )
            killRow[rows]["deathReason"] =      deathReason
            killRow[rows]["victimName"] =       tostring(victimName)
            killRow[rows]["victimNameColor"] =  tocolor( unpack(victimNameColor) )
    
        else
            killRow[rows] = {
                ["killerNamePos"] =     { leftX = label1_leftX, rightX = label1_rightX, topY = 0, bottomY = 0 },
                ["reasonIconPos"] =     { leftX = icon_leftX, topY = 0 },
                ["victimNamePos"] =     { leftX = label2_leftX, rightX = label2_rightX, topY = 0, bottomY = 0 },
    
                ["killerName"] =        tostring(killerName),
                ["killerNameColor"] =   tocolor( unpack(killerNameColor) ),
                ["deathReason"] =       deathReason,
                ["victimName"] =        tostring(victimName),
                ["victimNameColor"] =   tocolor( unpack(victimNameColor) )
            }
        end
    
        if imagePath[ killRow[rows]["deathReason"] ] == nil then
            killRow[rows]["deathReason"] = 255
        end
    
        if killRow[rows]["killerName"] == killRow[rows]["victimName"] then
            killRow[rows]["killerName"] = ""
        end
    
        local y = icon_topY
    
        for r = 1, rows do
            if killRow[r] then
                killRow[r]["killerNamePos"]["topY"] =       y + label_topMargin
                killRow[r]["killerNamePos"]["bottomY"] =    y + label_height
    
                killRow[r]["reasonIconPos"]["topY"] =       y
    
                killRow[r]["victimNamePos"]["topY"] =       killRow[r]["killerNamePos"]["topY"]
                killRow[r]["victimNamePos"]["bottomY"] =    killRow[r]["killerNamePos"]["bottomY"]
            end
    
            y = y + rows_margin
        end
    end
    
    addEvent("showDeathMessage", true )
    addEventHandler("showDeathMessage", resourceRoot, showClientDeathMessage )
    
    function killPanelTest()
    
        showClientDeathMessage( "oldPlayerName", { math.random(0,255), math.random(0,255), math.random(0,255) },
            "disconnected",
            "", {0,0,0} )
    
        for r = 2, rows - 1 do
            local c, nameLen, name1, name2 = 1, math.random(4,20), "", ""
    
            while c <= nameLen do
                name1 = name1 .. string.char( math.random(33,125) )
                c = c + 1
            end
    
            c, nameLen = 1, math.random(4,20)
            while c <= nameLen do
                name2 = name2 .. string.char( math.random(33,125) )
                c = c + 1
            end
    
            showClientDeathMessage( name1, { math.random(0,255), math.random(0,255), math.random(0,255) },
                math.random(0,54),
                name2, { math.random(0,255), math.random(0,255), math.random(0,255) } )
        end
    
        showClientDeathMessage( "newPlayerHere", { math.random(0,255), math.random(0,255), math.random(0,255) },
            "connected",
            "", {0, 0, 0} )
    end

     

     

  12. 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 )

     

  13. Spoiler
    
    local screenW, screenH = guiGetScreenSize()
    local maxRows, currentCell = 14, 0
    local openPanel = true
    
    local items = {
    	{"1",2000, 1},
    	{"2",2000, 1},
    	{"3",2000, 1},
    	{"4",2000, 1},
    	{"5",2000, 1},
    	{"6",2000, 1},
    	{"7",2000, 1},
    	{"8",2000, 1},
    	{"9",2000, 1},
    	{"10",2000, 1},
    	{"11",2000, 1},
    	{"12",2000, 1},
    	{"13",2000, 1},
    	{"14",2000, 1},
    	{"15",2000, 1},
    	{"16",2000, 1},
    	{"17",2000, 1},
    	{"18",2000, 1},
    	{"19",2000, 1},
    	{"20",2000, 1},
    	{"21",2000, 1},
    	{"22",2000, 1},
    	{"23",2000, 1},
    	{"24",2000, 1},
    	{"25",2000, 1},
    }
    
    if openPanel == true then
    	addEventHandler("onClientRender", root,
        function()
            dxDrawRectangle(screenW * 0.2516, screenH * 0.2843, screenW * 0.4974, screenH * 0.4352, tocolor(1, 2, 3, 147), false)
    
            dxDrawRectangle(screenW * 0.2516, screenH * 0.2611, screenW * 0.4807, screenH * 0.0231, tocolor(1, 2, 3, 193), false)
            dxDrawText("Shop v1.0", screenW * 0.2516, screenH * 0.2611, screenW * 0.7323, screenH * 0.2843, tocolor(255, 255, 255, 255), 1, "default-bold", "center", "center", false, false, false, false, false)
           
            dxDrawRectangle(screenW * 0.7323, screenH * 0.2611, screenW * 0.0167, screenH * 0.0231, tocolor(69, 0, 0, 193), false)
            dxDrawText("X", screenW * 0.7323, screenH * 0.2611, screenW * 0.7490, screenH * 0.2843, tocolor(255, 255, 255, 255), 1.00, "default-bold", "center", "center", false, false, false, false, false)
            
            dxDrawRectangle(screenW * 0.2536, screenH * 0.2889, screenW * 0.1906, screenH * 0.4213, tocolor(1, 2, 3, 90), false)
            
            dxDrawRectangle(screenW * 0.2568, screenH * 0.2981, screenW * 0.1833, screenH * 0.0250, tocolor(1, 2, 3, 90), false)
            dxDrawText("Item name", screenW * 0.2599, screenH * 0.2981, screenW * 0.3682, screenH * 0.3231, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "center", false, false, false, false, false)
            dxDrawText("$", screenW * 0.3682, screenH * 0.2981, screenW * 0.4016, screenH * 0.3231, tocolor(255, 255, 255, 255), 1.00, "default-bold", "center", "center", false, false, false, false, false)
            dxDrawText("Quantity", screenW * 0.4016, screenH * 0.2981, screenW * 0.4349, screenH * 0.3231, tocolor(255, 255, 255, 255), 1.00, "default-bold", "center", "center", false, false, false, false, false)
            for i = currentCell + 1, maxRows + currentCell do
            	local value = items[i]
            	local key = i - currentCell - 1
            	if value ~= nil then
            		dxDrawRectangle(screenW * 0.2568, screenH * 0.3269+((key)*27), screenW * 0.1781, screenH * 0.0250, tocolor(1, 2, 3, 90), false)
            		dxDrawText(value[1], screenW * 0.2599, screenH * 0.3269+(key*54), screenW * 0.3682, screenH * 0.3519, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "center", false, false, false, false, false)
    				dxDrawText(value[2], screenW * 0.3682, screenH * 0.3269+(key*54), screenW * 0.4016, screenH * 0.3519, tocolor(255, 255, 255, 255), 1.00, "default-bold", "center", "center", false, false, false, false, false)
    				dxDrawText(value[3], screenW * 0.4016, screenH * 0.3269+(key*54), screenW * 0.4349, screenH * 0.3519, tocolor(255, 255, 255, 255), 1.00, "default-bold", "center", "center", false, false, false, false, false)
        			if isCursorOnElement(screenW * 0.2568, screenH * 0.3269+(key*27), screenW * 0.1781, screenH * 0.0250) then
    					dxDrawRectangle(screenW * 0.2568, screenH * 0.3269+(key*27), screenW * 0.1781, screenH * 0.0250, tocolor(255, 255, 255, 90), false)
    				end
        		end
    		end
        end)
    end
    
    addEventHandler("onClientKey", root,
    function(button, state)
    	if openPanel then
    		if isCursorOnElement(screenW * 0.2536, screenH * 0.2889, screenW * 0.1906, screenH * 0.4389) then
    			if button == "mouse_wheel_up" and state then
    				if currentCell > 0 then
    					currentCell = currentCell - 1
    				end
    			elseif button == "mouse_wheel_down" and state then
    				if maxRows + currentCell < #items then
    					currentCell = currentCell + 1
    				end
    			end
    		end
    	end
    end)
    
    function isCursorOnElement( posX, posY, width, height )
    	if isCursorShowing( ) then
    		local mouseX, mouseY = getCursorPosition( )
    		local clientW, clientH = guiGetScreenSize( )
    		local mouseX, mouseY = mouseX * clientW, mouseY * clientH
    		if ( mouseX > posX and mouseX < ( posX + width ) and mouseY > posY and mouseY < ( posY + height ) ) then
    			return true
    		end
    	end
    	return false
    end

     

     

    • Thanks 1
  14. 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)

     

    • Like 1
  15. 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)

     

    • Thanks 1
×
×
  • Create New...