Jump to content

N3xT

Retired Staff
  • Posts

    2,490
  • Joined

  • Days Won

    18

Posts posted by N3xT

  1. 9 hours ago, IIYAMA said:

    Doesn't the event onClientKey detects hold? hmmm

     

    Well if it doesn't:

    Actually it does, you can use the second argument to detect if he's still pressing "holding" or not, so if he released the key this means he's not holding it anymore.

    • Like 1
  2. الكود يبغاله تحققات واضافات، لكن عموماً هذا توضيح للفكرة لا اكثر ولا اقل

    metatables والـ OOP او اذا عندك الخبرة الكافية استخدم الـ

    local dxlib = {}
    
    function dxCreateWindow()
        local window = createElement("dxWindow")
    
        dxlib[window] = {
            x = 0,
            y = 0,
            sx = 0,
            sy = 0
        }
    
        return window
    end
    
    function dxCreateButton(parent)
        local button = createElement("dxButton")
    
        dxlib[button] = {
            x = 0,
            y = 0,
            sx = 0,
            sy = 0
        }
    
        setElementParent(button, parent)
    end
    
    function toggleWindow(window)
        dxlib[window].show = false
        
        for _, children in ipairs(getElementChildren(window)) do
            if isElement(children) and dxlib[children] then
                dxlib[children].show = false
            end
        end
    end

     

  3. executeSQLQuery("CREATE TABLE IF NOT EXISTS `player_stats` (`username` TEXT, `Thirst` INT, `Hunger` INT)")
    
    addEventHandler("onPlayerQuit", root,
        function ()
            local account = getPlayerAccount(source)
            if ( isGuestAccount ( account ) ) then return end 
            
            local atsh = getElementData(source, "Thirst")
            local hungry = getElementData(source, "Hunger")
            local username = getAccountName(account)
    
            local result = executeSQLQuery("SELECT * FROM player_stats WHERE `username` = ?", username)
            if (result and #result > 0) then
                executeSQLQuery("UPDATE `player_stats` SET `Hunger` = ?, `Thirst` = ? WHERE `username` = ?", hungry, atsh, username)
            else
                executeSQLQuery("INSERT INTO health (username, Thirst, Hunger) VALUES (?, ?, ?)", username, atsh, hungry)
            end
        end
    )
    
    addEventHandler("onPlayerLogin", root, 
        function (_, account)
            local accountName = getAccountName(account)
            local result = executeSQLQuery("SELECT * FROM player_stats WHERE username = ?", accountName)
            if (result and #result > 0) then
                setElementData(source, "Thirst", result[1].Thirst)
                setElementData(source, "Hunger", result[1].Hunger)
            end
        end
    )

     

  4. 4 hours ago, Snakegold said:

    ما أشوف اخطاء؟

    local counter = executeSQLQuery("SELECT count FROM playerCounter") X
    local counter = executeSQLQuery("SELECT count FROM serial")
    
    executeSQLQuery("INSERT INTO savedSerials(serial) VALUES(?)",serial) X
    executeSQLQuery("INSERT INTO serial(savedSerials) VALUES(?)",serial)
    
    local q = executeSQLQuery("SELECT username FROM serialUsername WHERE serial=?",serial) X
    local q = executeSQLQuery("SELECT serialUsername FROM serial WHERE savedSerials=?",serial)

    وكل الباقية خطأ

  5. 2 minutes ago, iwalidza said:


    يعني اقدر اسوي اكثر من شيء داخل الفنكشن و اطلعه وقت ما ابي صحيح؟
     

    
    local functions = {
        outputText = function ( ... )
            outputChatBox ( ... )
        end,
      	outputTextAdmin = function( ... )
        	outputChatBox ("From Admin :" ... )
        end,
    }
    
    functions.outputTextAdmin ( "We need learn :)", root, 255, 255, 255, true )
    

     

     

    outputChatBox ( "From Admin :" .. ... )

     

    • Like 1
  6. 3 hours ago, Ahmed Ly said:

    اول شي كود سيرفر او كلنت 

    ثاني شي انت وش تبغي تسوي 

    واخر  شي حط كودك الميتا 

    وكودك مفروض كذا 

     لو كلنت 

    outputChatBox("hello world",localPlayer,255,0,0)

     

    الكلينت مافيه ارقمنت للاعب, تكتب رسالتك على طول

    outputChatBox("test")

     

    • Sad 1
  7. On 26/03/2020 at 19:36, Santi said:
    
    function hex2rgb (hex)
        local hex = hex:gsub("#","")
        if hex:len() == 3 then
          return (tonumber("0x"..hex:sub(1,1))*17)/255, (tonumber("0x"..hex:sub(2,2))*17)/255, (tonumber("0x"..hex:sub(3,3))*17)/255
        else
          return tonumber("0x"..hex:sub(1,2))/255, tonumber("0x"..hex:sub(3,4))/255, tonumber("0x"..hex:sub(5,6))/255
        end
    end
    
    -- exemple usage: (NOT TESTED the command) but the function works fine
    
    addEventHandler("onPlayerCommand",root,
        function(command, player)
    	if (command == "convert") then
    	    outputConsole("Result: " .. hex2rgb("#ffffff"),player)
    	end
    end)
    

    :)

    Use addCommandHandler to create a command, also the source of onPlayerCommand is the player. so you don't need to add player as a parameter.

  8. 1 hour ago, unsiXioN said:

    ي هلا وغلا يالله حيه

    الحمد لله بخير ، التفاعل في المنتدى اشوفه ميت عالآخر وأيضاً نفس الشيء في اللعبة !

     

    المنتدى ممكن يكون قل تفاعله بالقسم العربي, لكن القسم الأجنبي كمثال لا زال متفاعل وبقوة

    اللعبة يومياً تحقق ارقام قياسية جديدة, تأكد من معلوماتك

    • Like 1
  9. كلاينت

    local screenWidth, screenHeight = guiGetScreenSize ()
    
    function hud ()
        local team = getPlayerTeam ( localPlayer )
        if ( team ) then
            local teamID = getElementData ( team, "id" )
            if ( teamID and tonumber ( teamID ) == 1 ) then
                dxDrawText ( "Police", screenWidth*0.910, screenHeight*0.196, screenWidth*0.986, screenHeight*0.227, tocolor ( 255, 255, 255, 255 ), 2.00, "default-bold", "center", "center", false, false, false, false, false )
            end
        end
    end
    addEventHandler ( "onClientRender", root, hud )
×
×
  • Create New...