dam034 Posted October 1, 2017 Share 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 Link to comment
Moderators IIYAMA Posted October 1, 2017 Moderators Share Posted October 1, 2017 Debug your code properly. And make sure you enable screenshot upload in you MTA settings. Link to comment
dam034 Posted October 1, 2017 Author Share 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 Link to comment
Moderators IIYAMA Posted October 1, 2017 Moderators Share Posted October 1, 2017 Login as Admin Write the command: /debugscript 3 Link to comment
dam034 Posted October 2, 2017 Author Share Posted October 2, 2017 Can I use outputConsole(), so it's easier for me? Link to comment
Moderators IIYAMA Posted October 2, 2017 Moderators Share 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(). Link to comment
dam034 Posted October 2, 2017 Author Share 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 Link to comment
pa3ck Posted October 2, 2017 Share 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. Link to comment
dam034 Posted October 3, 2017 Author Share 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 Link to comment
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