dam034 Posted October 1, 2017 Posted October 1, 2017 Dear users, as you know, I'm scripting a MTA server on my LAN test server. I have problems about screenshots, this is the resource code serverside: function scatta(risx, risy) takePlayerScreenShot(client, risx, risy, getPlayerName(client), 100, 10000000) end function salvala(ris, stato, immstr, tick, param) local mom = getRealTime() if(stato == 'ok') then local ha = fileCreate('imm-'..param..'-'..tostring(mom['timestamp'])..'.jpg') if(ha) then fileWrite(ha, immstr) fileClose(ha) end end triggerClientEvent(getPlayerFromName(param), 'fotoritorno', '', stato) end addEvent('fotofalla', true) addEventHandler("fotofalla", getRootElement(), scatta) addEventHandler("onPlayerScreenShot", getRootElement(), salvala) And this is clientside: function falla() local x,y = guiGetScreenSize() triggerServerEvent('fotofalla', x, y) end function risu(stato) outputChatBox('Risultato funzione: '..stato) end addCommandHandler('faifoto', falla) addEvent('fotoritorno', true) addEventHandler("fotoritorno", getRootElement(), risu) As you can see, I wrote the variables' name in my language (so you know), and I can use serverside only to take screenshot, except for taking screen resolution from client. This script doesn't work. Where I did mistakes? Thanks dam034 I'm developing a revolution for MTASA
Moderators IIYAMA Posted October 1, 2017 Moderators Posted October 1, 2017 Debug your code properly. And make sure you enable screenshot upload in you MTA settings. Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
dam034 Posted October 1, 2017 Author Posted October 1, 2017 The screenshot is surely enabled in MTA settings because before this script, I used one only serverside, without take the screen resolution from the client and it worked. Then, where can I see the debug console to read the messages I'll write? Thanks dam034 I'm developing a revolution for MTASA
Moderators IIYAMA Posted October 1, 2017 Moderators Posted October 1, 2017 Login as Admin Write the command: /debugscript 3 Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
dam034 Posted October 2, 2017 Author Posted October 2, 2017 Can I use outputConsole(), so it's easier for me? dam034 I'm developing a revolution for MTASA
Moderators IIYAMA Posted October 2, 2017 Moderators Posted October 2, 2017 You can do that, but that one is only visible in the ingame console.(Key to open: F8) If you want to make it visible in the server console, use print(). Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
dam034 Posted October 2, 2017 Author Posted October 2, 2017 I added debug functions in my code as outputChatBox(), to test it. Now this is the code serverside: function scatta(risx, risy) outputChatBox('fase 2 - x: '..tostring(risx)..' - y: '..tostring(risy)) takePlayerScreenShot(client, risx, risy, getPlayerName(client), 100, 10000000) end function salvala(ris, stato, immstr, secondi, param) local mom = getRealTime() if(stato == 'ok') then local ha = fileCreate('imm-'..param..'-'..tostring(mom['timestamp'])..'.jpg') if(ha) then fileWrite(ha, immstr) fileClose(ha) end end outputChatBox('fase 3 - nome: imm-'..param..'-'..tostring(mom['timestamp'])..'.jpg - stato: '..stato) triggerClientEvent(getPlayerFromName(param), 'fotoritorno', '', stato) end addEvent('fotofalla', true) addEventHandler("fotofalla", getRootElement(), scatta) addEventHandler("onPlayerScreenShot", getRootElement(), salvala) And this is clientside: function falla() local x,y = guiGetScreenSize() outputChatBox('fase 1 - x: '..tostring(x)..' - y: '..tostring(y)) triggerServerEvent('fotofalla', x, y) end function risu(stato) outputChatBox('Risultato funzione: '..stato) end addCommandHandler('faifoto', falla) addEvent('fotoritorno', true) addEventHandler("fotoritorno", getRootElement(), risu) And this is meta.xml <meta> <info author="dam034" version="1.1" type="misc" /> <script src="foto-s.lua" type="server" /> <script src="foto-c.lua" type="client" /> </meta> Testing all the code, trying with the command /faifoto, in the chatbox I see only "fase 1 - ...", so I think it work up to the function falla(). So I want to know: where I did wrong? Thanks dam034 I'm developing a revolution for MTASA
pa3ck Posted October 2, 2017 Posted October 2, 2017 That's right, it only goes as far as fase 1, the reason is, triggerServerEvent requires an element (player or root). Try this: triggerServerEvent('fotofalla', localPlayer, x, y) BTW: variable "secondi" is already the timestamp, you don't really need to get the getRealTime().timestamp, since it's already there.
dam034 Posted October 3, 2017 Author Posted October 3, 2017 15 hours ago, pa3ck said: That's right, it only goes as far as fase 1, the reason is, triggerServerEvent requires an element (player or root). Try this: triggerServerEvent('fotofalla', localPlayer, x, y) And serverside what source I need to write? 15 hours ago, pa3ck said: BTW: variable "secondi" is already the timestamp, you don't really need to get the getRealTime().timestamp, since it's already there. I saw it isn't exactly what I want, because it returns tick count, but I need the timestamp as PHP time() function. Thanks dam034 I'm developing a revolution for MTASA
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now