Jump to content

when player take a screenshot


Recommended Posts

Hello

You can use this script client side :

addEventHandler("onClientKey", root, function(button,press) 
    if press and (button == getKeyBoundToCommand("screenshot")) then
        outputChatBox("You have taken a screenshot !")
    end
end)

 

Edited by Mkl
Link to comment
12 hours ago, Mkl said:

Hello

You can use this script client side :


addEventHandler("onClientKey", root, function(button,press) 
    if press and (button == getKeyBoundToCommand("screenshot")) then
        outputChatBox("You have taken a screenshot !")
    end
end)

 

hello i changed script like;

When I take a screenshot, it prints the time and date correctly, but in the next screenshots, it continues to write the date and time in the chat that I took the first screenshot.

local hour = getRealTime().hour
local minute = getRealTime().minute
local second = getRealTime().second
local day = getRealTime().monthday
local month = getRealTime().month+1
local year = getRealTime().year+1900
 
addEventHandler("onClientKey", root, function(button,press
    if press and (button == getKeyBoundToCommand("screenshot")) then
        outputChatBox("You have taken a screenshot ! mta-screen_"..year.."-"..month.."-"..day.."_"..hour.."-"..minute.."-"..second..".png"25500true)
    end
end)
Link to comment

Include the variables inside the functiun and not outside (and inside the condition).

-- local hour = ...
-- will get values when the script starts

addEventHandler("onClientKey", root, function(button,press) 
	-- local hour = ...
	-- will get values everytime a player press on a key
    if press and (button == getKeyBoundToCommand("screenshot")) then
		-- local hour = ...
		-- will get values when the key is the screenshot command
        outputChatBox("You have taken a screenshot ! mta-screen_"..year.."-"..month.."-"..day.."_"..hour.."-"..minute.."-"..second..".png", 255, 0, 0, true)
    end
end)

 

Edited by Mkl
  • Like 1
Link to comment
39 minutes ago, Mkl said:

Include the variables inside the functiun and not outside (and inside the condition).


-- local hour = ...
-- will get values when the script starts

addEventHandler("onClientKey", root, function(button,press) 
	-- local hour = ...
	-- will get values everytime a player press on a key
    if press and (button == getKeyBoundToCommand("screenshot")) then
		-- local hour = ...
		-- will get values when the key is the screenshot command
        outputChatBox("You have taken a screenshot ! mta-screen_"..year.."-"..month.."-"..day.."_"..hour.."-"..minute.."-"..second..".png", 255, 0, 0, true)
    end
end)

 

it's done thank you very much

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...