Jump to content

Screenshot problem


dam034

Recommended Posts

Posted

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
Posted

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 

  Tutorials  4x 

 

Posted

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
Posted
  1. Login as Admin
  2. 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 

  Tutorials  4x 

 

  • Moderators
Posted

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 

  Tutorials  4x 

 

Posted

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

Posted

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. 

Posted
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

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...