Jump to content

Script bug


xeon17

Recommended Posts

I got a bug with my screenshot script , idk how to solve..

--Server

- Modifikuj -- 
LocX = 50  -- Lokacija slike X 
LocY = 50  -- Lokacija slike Y 
ImageSizeX = 320 -- Sirina slike 
ImageSizeY = 240  -- Visina slike 
ImageTimer = 10   -- Koliko ce dugo vremena slika biti prikazana (u sekundama) 
Quality = 30   -- Kvaliteta slike od 0 do 100 
MaxBandwith = 5000  -- Maksimalna brzina slanja slike u Bps (Byte-u po sekundi) 
  
-- Ne modifikuj -- 
CurrentAdmin = nil 
  
function getPic(player,command,arg1) 
    if (arg1) then 
        local PlayerX = getPlayerFromID(tonumber(arg1)) 
        if (PlayerX) then 
            CurrentAdmin = player 
            takePlayerScreenShot(PlayerX,ImageSizeX,ImageSizeY,nil,Quality,MaxBandwith) 
        else 
            outputChatBox("Incorrect player ID!",player) 
        end 
    else 
        outputChatBox("Please enter player ID!",player) 
    end 
end 
addCommandHandler("ss",getPic,false,false) 
  
function onPlayerScreenShotz(res,status,jpeg,timestamp,tag) 
    local player = CurrentAdmin 
    if (status == "ok") then 
        outputChatBox("Screenshot from: " .. tostring(getPlayerName(source)),player) 
        triggerClientEvent(player,"drawMeTheImage",player,jpeg,LocX,LocY,ImageSizeX,ImageSizeY,ImageTimer) 
    elseif (status == "disabled") then 
        outputChatBox("That player has disabled taking screenshots of their screen!",player) 
    elseif (status == "minimized") then 
        outputChatBox("That player has alt-tabbed at this moment!",player) 
    end 
end 
addEventHandler("onPlayerScreenShot",getRootElement(),onPlayerScreenShotz) 

--Client

function drawMeTheImage(jpeg,LocX,LocY,ImageSizeX,ImageSizeY,ImageTimer) 
    cjpeg = jpeg 
    cLocX = LocX 
    cLocY = LocY 
    cISX = ImageSizeX 
    cISY = ImageSizeY 
    drawimg = true 
    setTimer(disdraw,ImageTimer * 1000,1) 
end 
addEvent("drawMeTheImage", true) 
addEventHandler("drawMeTheImage",getLocalPlayer(),drawMeTheImage) 
  
function disdraw() 
    drawimg = nil 
end 
  
function renderx() 
    if (drawimg) then 
        dxDrawImage(cLocX,cLocY,cISX,cISY,cjpeg) 
    end 
end 
addEventHandler("onClientRender",getRootElement(),renderx) 

The text in Server side is from my language ._.

Client bug , bad file path dxDrawImage line 19

Link to comment

Like this ?

-------------------------------------------------- 
-- Turn image data into a texture at the client 
addEvent("onMyClientScreenShot",true) 
addEventHandler( "onMyClientScreenShot", resourceRoot, 
    function(player, pixels ) 
        if image then 
            destroyElement(image) 
            image = nil 
        end 
        if(pixels) then 
            image = dxCreateTexture( pixels ) 
        end 
        screenShotPlayer = player; 
    end 
) 
  
-------------------------------------------------- 
-- Show image 
addEventHandler( "onClientRender", root, 
    function() 
        if image and  isElement(screenShotPlayer) then 
            dxDrawImage( 100, 250, 400, 300, image ) 
            dxDrawText("SS - ".. getPlayerName(screenShotPlayer), 100, 250, 400, 300, tocolor ( 255, 255, 255, 255 ), 1, "pricedown" ) 
        end 
         
        if myTexture then 
            local sw,sh = guiGetScreenSize () 
            local w,h = dxGetMaterialSize( myTexture ) 
            dxDrawImage( 10, sh/2-h/2, w, h, myTexture ) 
        end      
         
    end 
) 
  
  
  
addEvent( "onClientGotImage", true ) 
addEventHandler( "onClientGotImage", resourceRoot, 
    function( pixels ) 
        if(pixels) then 
            myTexture = dxCreateTexture( pixels ) 
        else 
            myTexture = nil 
        end 
    end 
) 
  
  
  
  
local keyTable = { "mouse1", "mouse2", "mouse3", "mouse4", "mouse5", "mouse_wheel_up", "mouse_wheel_down", "arrow_l", "arrow_u", 
 "arrow_r", "arrow_d", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", 
 "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "num_0", "num_1", "num_2", "num_3", "num_4", "num_5", 
 "num_6", "num_7", "num_8", "num_9", "num_mul", "num_add", "num_sep", "num_sub", "num_div", "num_dec", "F1", "F2", "F3", "F4", "F5", 
 "F6", "F7", "F8", "F9", "F10", "F11", "F12", "backspace", "tab", "lalt", "ralt", "enter", "space", "pgup", "pgdn", "end", "home", 
 "insert", "delete", "lshift", "rshift", "lctrl", "rctrl", "[", "]", "pause", "capslock", "scroll", ";", ",", "-", ".", "/", "#", "\\", "=" } 
  
  
addEvent( "onRequestCommandsBoundToKey", true ) 
addEventHandler( "onRequestCommandsBoundToKey", root, 
    function( theKey, keyState ) 
        triggerServerEvent("onResponseCommandsBoundToKey", localPlayer,theKey, keyState, getCommandsBoundToKey( theKey, keyState )) 
    end 
) 
  
  
  

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