Hugos
-
Posts
172 -
Joined
-
Last visited
Posts posted by Hugos
-
-
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)
-
I need to get the amount of money from the table and give the money to the player.
addEvent("PlayerSpawn", true) function PlayerSpawn() setPlayerMoney(?, ?) end addEventHandler("PlayerSpawn", root, PlayerSpawn)
Could you tell me please, as this can be done?
-
And if you configure the rights. Function onClientResourceStart?
-
9 hours ago, keymetaphore said:
Retrieve the information from database and use givePlayerMoney to award it.
Yes. How do I get "Money" from the database?
10 hours ago, stPatrick said:Thanks!
-
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)
Spoiler2. 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?
-
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 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!
-
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)
-
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.
-
13 minutes ago, IIYAMA said:
oh really, that is so amazing!
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?
-
2 hours ago, IIYAMA said:
triggerClientEvent(player, "error", root)
? not work.
-
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
-
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?
-
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?
-
Hi. Prompt whether it is possible to create function in a resource which would start other resource?
-
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!
-
33 minutes ago, majqq said:
I believe that's happening because timer is going all the time, removing event handler doesn't make that timer will be destroyed. Timer is set for 1 ms interval, and unlimited times to execute.
https://wiki.multitheftauto.com/wiki/SetTimer
Try to assign timer to variable, and kill it after removing event handler, with:
Oh, Thank!
-
6 minutes ago, majqq said:
Any errors/warnings?
Show removeEventHandler line.
I use:
removeEventHandler("onClientGUIClick", btn, btn_edit)
But the function and the text is not hiding
-
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! -
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" -
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!
-
Please tell me whether it is possible to "dxDrawRectangle" to attach the function "onClientGUIClick"? If so, then how to do it?
-
I use "guiSetAlpha", the field is hidden and the cursor remains.
P.S: + What is this script?
-
Is it possible to remove the cursor from "guiCreateEdit"? (so far found only "guiEditSetCaretIndex")
KickPlayer
in Scripting
Posted · Edited by Hugos
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.)