Hugos

Members
  • Content Count

    74
  • Joined

  • Last visited

Posts posted by Hugos


  1. 13 hours ago, DNL291 said:

    dbQuery, dbPoll

    Syntax looks like: 

    
    SELECT x,y,z FROM player WHERE username=?
    

    Try to do it, and show here your code. You can also search through the forum, wiki... there are codes made.

    Thanks!



  2. I have a table "player." It has the fields "username" and coordinates "x", "y", "z".
    How do I spam the player on the saved coordinates.

    ???


  3. 10 minutes ago, majqq said:

     Are you sure that is good idea? What if he will be downloading resources more than 5 minutes? :D

    Besides few advices.

     Player in event is defined as:

    
    source
    

    From wiki:

    52P7iSM.png

    You don't need to "create" function within timer, for me it's simpler to use following syntax. Also, time interval is 5000 ms, 5 minutes = 300 000 ms. Take a look at `times to execute`, it's unlimited, most likely it will throw out errors, because defined player doesn't exist, if he will quit.

    
    -- From wiki
    
    setTimer ( function theFunction, int timeInterval, int timesToExecute [, var arguments... ] )
      
    --
    	-- Function, interval, times to execute, argument1, argument2
    setTimer(kickPlayer, 300000, 1, source, "Reason")
    

      

    What better way? To players who are not logged in did not occupy the slots? (the player will go to the server and will not enter the account, and the slot will be busy - until he leaves the server.)


  4. Help! I need to make a timer function to kick a player who is not spawn 5 minutes after join. How to do it correctly?
     

    function PlayerJoin()
      	...
      	...
      	...
    	setTimer(function()
        	kickPlayer(? ? ?)
    	end, 5000, 0)
    end
    addEventHandler("onPlayerJoin", root, PlayerJoin)

     


  5. I need to get the amount of money from the table and give the money to the player.

    hTbKU62.png

    addEvent("PlayerSpawn", true)
    function PlayerSpawn()
    	setPlayerMoney(?, ?)
    end
    addEventHandler("PlayerSpawn", root, PlayerSpawn)

    Could you tell me please, as this can be done?
     


  6. 2 question (please help to solve them):

    1. Is it possible to hide the health bar and nick, the other players? (so that they are not displayed to anyone)

    Spoiler

    23WRoeW.png

    2. I have a table in MySQL, where saved "logins" and "amount of money", how do I give money at the entrance of the player, based on the information in the database?
     


  7. On 22/03/2019 at 01:39, IIYAMA said:

    @TorNix~|nR

    That is not how this works. A table is a thing, it is something even if it is empty.

    
    if {} then
    	outputChatBox("Always true")
    end
    

     

    
    local players = getElementsByType("player") 
    
    
    for index,thisPlayer in pairs(#players > 0 and players or getElementsByType("ped")) do
    

     

    Note, this does not merge the tables. Just uses peds when there are no players.

    I have "edixBox" from which I get the result (variable - result), how to check if there is such a player on the server (with the same name)?
     


  8. 8 hours ago, IIYAMA said:
    
    local playerList = getElementsByType("player")
    

     

    https://wiki.multitheftauto.com/wiki/GetElementsByType

     

    Player names are irrelevant, the thing that matters are elements. Players are also elements. In Lua those are accessed with userdata values. Userdata's are unique values that are used as element identifiers.

     

    Take a closer look. Clientside:

    
    outputChatBox(tostring(localPlayer))
    

     

     

     

    Thanks!


  9. Help. What function is responsible for the list of all players. To the connections to check whether the server is the player with the same name (I'm early get the player's name)
     


  10. 14 minutes ago, IIYAMA said:

    To define the player element, which receives the message.

    command: /hey

     

    So yes you don't need the addCommandHandler, if you have an alternative to define the player.

      

     

    Thank you, I got it. 


  11. 13 minutes ago, IIYAMA said:

    oh really, that is so amazing! :thumbup:

      

    
    addCommandHandler("hey", 
    function (player)
    	triggerClientEvent(player, "error", root)
    end)
    

     

    
    addEvent("error", true)
    function showError()
        addEventHandler("onClientRender", root, redline)
    end
    addEventHandler("error", root, showError)
    

      

    What is it? addCommandHandler - why I need?


  12. addEvent("CheckName", true)
    function OnPlayerCheck(name)
    	qh_name = dbQuery(db, "SELECT * FROM dbQuery WHERE name=?", rname) --Find the row in the table
    	local result = dbPoll(qh_name, -1)
    	if #result >= 1 then --if the result is correct
      	outputToChat(" " ..result.. " say: " ..message, v, 255, 100, 200, true)
    	else
    	--endIf the "name" is incorrect
    end
    addEventHandler("CheckName", root, CheckName)

    Server

    text = guiCreateEdit(0, 0, 0, 0, "", false)
    
    function btn(button) --function if the player pressed the button.
        if button == "left" then
    	local CheckName = guiGetText(text) --Get the name - from the edit field (guiCreateEdit)
    	triggerServerEvent("CheckName", getLocalPlayer(), name) --Server
        end
    end
    

    Client

     

    In this example, I get the name of the player that he enters in "guiCreateEdit" >> Find it in the database >> If found, output the text
     


  13. 4 hours ago, slapz0r said:

    Created a table called "123" with columns "login, "name"

    Created a table with dbQuery

    How can I make a chat message from the column "name" ?

    or just in label 

    Smth like that 

    
    outputToChat(" " ..getPlayerName(source).. " say: " ..message, v, 255, 100, 200, true)
    

    but instead getPlayerName(source) need information from the column (name)

    Do you need to get a name from the table?
     


  14. Help.

    When you click on the start Server-trigger >> account is checked >> the lrient trigger is started >> the function is triggered >> the line is displayed, but it is not displayed for the player who pressed the button, but for all players. Here's the code:

    Server:
    triggerClientEvent("error", root)
    
    Client:
    addEvent("error", true)
    function error()
        addEventHandler("onClientRender", root, redline)
    end
    
    function redline()
        dxDrawLine(448, 435, 917, 435, tocolor(240, 75, 90), 2, true)
    end

    How to make something appear only for the player who pressed the button?
     


  15. 12 hours ago, N3xT said:

    By the way, using a timer inside a render event is useless because 'onClientRender' event gets triggered everytime GTA renders a new frame.

    Only now understood. Thank you for making my life easier and code! 🧐


  16. I have such a function:

    function btn_edit(button)
        if button == "left" then
            name = guiCreateEdit(0, 0, 0, 0, "", false)
            setTimer(function()
                dxDrawText(guiGetText(name), 455, 316, 690, 346, tocolor(255, 255, 255), 1, Font13, "left", "center", clip, wordBreak, true) 
                guiFocus(name)
                guiSetAlpha(name, 0)
                guiEditSetMaxLength(name, 32)
            end, 1, 0)
        end
    end
    
    ( addEventHandler("onClientGUIClick", btn, btn_edit)  )

    Does not work "removeEventHandler". In another function, when I click I hide all the specified functions except this one.
    I can't understand why she's not hiding. Help, please!


  17. On 13/06/2019 at 17:00, salh said:

    use 

    
    function isMouseInPosition ( x, y, width, height )
    	if ( not isCursorShowing( ) ) then
    		return false
    	end
        local sx, sy = guiGetScreenSize ( )
        local cx, cy = getCursorPosition ( )
        local cx, cy = ( cx * sx ), ( cy * sy )
        if ( cx >= x and cx <= x + width ) and ( cy >= y and cy <= y + height ) then
            return true
        else
            return false
        end
    end
    
    addEventHandler ( "onClientClick", root,
        function ( button, state )
            if ( button == "left" and state == "down" ) then
                if ( isMouseInPosition ( the postion of the button ) ) then
    		-- code
                end
            end
        end
    )
    

     

    Found another way, easier:
    Create "guiCreateLabel (x, y, width, height, "", false)", where x, y, width and height are the same as " dxDrawRectangle", and create function "onClientGUIClick"
    ;)


  18. On 13/06/2019 at 17:00, salh said:

    use 

    
    function isMouseInPosition ( x, y, width, height )
    	if ( not isCursorShowing( ) ) then
    		return false
    	end
        local sx, sy = guiGetScreenSize ( )
        local cx, cy = getCursorPosition ( )
        local cx, cy = ( cx * sx ), ( cy * sy )
        if ( cx >= x and cx <= x + width ) and ( cy >= y and cy <= y + height ) then
            return true
        else
            return false
        end
    end
    
    addEventHandler ( "onClientClick", root,
        function ( button, state )
            if ( button == "left" and state == "down" ) then
                if ( isMouseInPosition ( the postion of the button ) ) then
    		-- code
                end
            end
        end
    )
    

     

    Thank!