Jump to content

Zuher Laith

Members
  • Posts

    148
  • Joined

  • Last visited

Everything posted by Zuher Laith

  1. It might work but .. Any Example's or something please ?
  2. Hello Everyone .. So i recently got this code from one of youtube videos .. It Count's how many player time is in server (HH-MM-SS) So the Code doesn't have any problem .. Except, When i Turn off the Server, it doesn't Save the Score, and restore it to 00-00-00 Here is the Full Code: exports.scoreboard:addScoreboardColumn('PlayTime') local t = { } function checkValues( source,arg1,arg2) if (arg2 >= 60) then t[ source ][ 'min' ] = tonumber( t[ source ][ 'min' ] or 0 ) + 1 t[ source ][ 'sec' ] = 0 end if (arg1 >= 60) then t[ source ][ 'min' ] = 0 t[ source ][ 'hour' ] = tonumber( t[ source ][ 'hour' ] or 0 ) + 1 end return arg1, arg2 end setTimer( function( ) for _, v in pairs( getElementsByType( "player" ) ) do if (not t[ v ]) then t[ v ] = { ["hour"] = 0, ["min"] = 0, ["sec"] = 0 } end t[ v ][ 'sec' ] = tonumber( t[ v ][ 'sec' ] or 0 ) + 1 local min,sec = checkValues ( v, t[ v ][ 'min' ] or 0, t[ v ][ 'sec' ] or 0 ) local hour = tonumber( t[ v ][ 'hour' ] or 0 ) setElementData( v, "PlayTime", tostring( hour )..':'..tostring( min )..':'..tostring( sec ) ) end end, 1000, 0 ) function onPlayerQuit ( ) local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) and not isGuestAccount ( playeraccount ) then local sValue = getElementData( source,'PlayTime' ) local hour = tonumber( t[ source ][ 'hour' ] or 0 ) local min = tonumber( t[ source ][ 'min' ] or 0 ) local sec = tonumber( t[ source ][ 'sec' ] or 0 ) setAccountData ( playeraccount, "PlayTime-hour", tostring(hour) ) setAccountData ( playeraccount, "PlayTime-min", tostring(min) ) setAccountData ( playeraccount, "PlayTime-sec", tostring(sec) ) setAccountData ( playeraccount, "PlayTime", tostring(sValue) ) end t[ source ] = nil end function onPlayerLogin (_, playeraccount ) if ( playeraccount ) then local time = getAccountData ( playeraccount, "PlayTime" ) local hou = getAccountData ( playeraccount, "PlayTime-hour") local min = getAccountData ( playeraccount, "PlayTime-min") local sec = getAccountData ( playeraccount, "PlayTime-sec") if ( time ) then setElementData ( source, "PlayTime", time ) t[ source ]["hour"] = tonumber(hou) t[ source ]["min"] = tonumber(min) t[ source ]["sec"] = tonumber(sec) else setElementData ( source, "PlayTime",0 ) setAccountData ( playeraccount, "PlayTime",0 ) end end end addEventHandler ( "onPlayerQuit", root, onPlayerQuit ) addEventHandler ( "onPlayerLogin", root, onPlayerLogin ) Any Help ? ..
  3. Sorry for late respond. The Full for dx_text.lua: dxText = class ( 'dxText', dxGUI ) function dxText:create ( x, y, width, height, text, parent ) if not (x and y and width and height) then return; end local self = setmetatable({}, {__index = self}) self.type = "text" self.text = text or ""; self.x = x self.y = y self.width = width self.height = height self.font = "default" self.scale = 1 self.alignX = "left" self.alignY = "top" self.clip = false self.wordbreak = false self.color = {255, 255, 255, 255} self.visible = true self.render = true if parent then self.render = false self.parent = parent table.insert(parent.children, self) end table.insert(dxObjects, self) return self end dxText.new = dxText.create; function dxText:setAlignX ( alignX ) if (not alignX) then return; end self.alignX = alignX end function dxText:getAlignX ( ) return self.alignX end function dxText:setAlignY ( alignY ) if (not alignY) then return; end self.alignY = alignY end function dxText:getAlignY ( ) return self.alignY end function dxText:setClip ( clip ) self.clip = clip end function dxText:getClip ( ) return self.clip end function dxText:setWordbreak ( wordbreak ) self.wordbreak = wordbreak end function dxText:getWordbreak ( ) return self.wordbreak end function dxText:draw ( ) --dxDrawRectangle(self.x, self.y, self.width, self.height, tocolor(0, 0, 0, 150)) dxDrawText(self.text, self.x, self.y, self.x + self.width, self.y + self.height, tocolor(unpack(self.color)), self.scale, self.font, self.alignX, self.alignY, self.clip, self.wordbreak, false) end
  4. Here it is .. gui = {}; -- Business Window gui.b = {label = {}, tab = {}, edit = {}, button = {}}; local width, height = 524, 300; local x = screen_width/2 - width/2; local y = screen_height/2 - height/2; gui.b.window = dxWindow(x, y, width, height, "اسم الوظيفة", false); gui.b.window.visible = false; gui.b.window:setTitleColor(125, 0, 0); gui.b.tab_panel = dxTabPanel(5, 50, 511, 231, gui.b.window); gui.b.tab.info = dxTab("المعلومات", gui.b.tab_panel); gui.b.label.id = dxText(10, 20, 81, 16, "الرقم: #", gui.b.tab.info); gui.b.label.name = dxText(10, 70, 241, 16, "الاسم:", gui.b.tab.info); gui.b.label.owner = dxText(10, 120, 231, 16, "المالك: ", gui.b.tab.info); gui.b.label.cost = dxText(10, 170, 191, 16, "السعر: ", gui.b.tab.info); gui.b.label.payout = dxText(290, 20, 211, 16, "الراتب: ", gui.b.tab.info); gui.b.label.payout_time = dxText(290, 70, 211, 16, "الدفع كل:", gui.b.tab.info); gui.b.label.location = dxText(290, 120, 211, 16, "الموقع:", gui.b.tab.info); gui.b.label.bank = dxText(290, 170, 211, 16, "البنك:", gui.b.tab.info); gui.b.label.id:setAlignX("left", false); gui.b.label.id:setAlignY("center"); gui.b.label.name:setAlignX("left", false); gui.b.label.name:setAlignY("center"); gui.b.label.owner:setAlignX("left", false); gui.b.label.owner:setAlignY("center"); gui.b.label.cost:setAlignX("left", false); gui.b.label.cost:setAlignY("center"); gui.b.label.payout:setAlignX("left", false); gui.b.label.payout:setAlignY("center"); gui.b.label.payout_time:setAlignX("left", false); gui.b.label.payout_time:setAlignY("center"); gui.b.label.location:setAlignX("left", false); gui.b.label.location:setAlignY("center"); gui.b.label.bank:setAlignX("left", false); gui.b.label.bank:setAlignY("center"); PS: You may find some arabic letters , don't give them attention.
  5. Thanks for The Tip .. It's Very helpful but still not the Solution for My Problem .. function dxText:create ( x, y, width, height, text, parent ) if not (x and y and width and height) then return; end local self = setmetatable({}, {__index = self}) myFont = guiCreateFont( "Font.ttf", 2 ) if myFont == false then myFont = guiCreateFont( "Font.ttf", 2 ) end self.type = "text" self.text = text or ""; self.x = x self.y = y self.width = width self.height = height self.font = myFont --self.scale = 1 self.alignX = "left" self.alignY = "top" self.clip = false self.wordbreak = false self.color = {255, 255, 255, 255} self.visible = true self.render = true if parent then self.render = false self.parent = parent table.insert(parent.children, self) end table.insert(dxObjects, self) return self end
  6. Still Unsolved .. Any one have an idea about this ?
  7. @ALw7sH Thanks for the Idea .. After Some editing .. it Seem's this is the Right Solution: Problem Solved.
  8. Same problem .. local myFont = guiCreateFont( "Font.ttf", 2 ) if myFont == false then local myFont = guiCreateFont( "Font.ttf", 2 ) end
  9. What i tried Currently ..: xBindFunction_ = function () --function(player) if getElementData("F10") ~= true then --canelEvent() elseif getElementData("F10") ~= false then guiSetVisible(GiveAdmin.Background ,not guiGetVisible(GiveAdmin.Background)); showCursor(guiGetVisible(GiveAdmin.Background)); end end bindKey(Key,"down",xBindFunction_); Doesn't Work .. What's the problem ? any help please ? ..
  10. local myFont = guiCreateFont( "Font.ttf", 2 ) if myFont = false then local myFont = guiCreateFont( "Font.ttf", 2 ) end The GUI Started not Showing up, No Error Given. The Full Code: function dxText:create ( x, y, width, height, text, parent ) if not (x and y and width and height) then return; end local self = setmetatable({}, {__index = self}) local myFont = guiCreateFont( "Font.ttf", 2 ) if myFont = false then local myFont = guiCreateFont( "Font.ttf", 2 ) end self.type = "text" self.text = text or ""; self.x = x self.y = y self.width = width self.height = height self.font = "default" self.scale = 1 self.alignX = "left" self.alignY = "top" self.clip = false self.wordbreak = false self.color = {255, 255, 255, 255} self.visible = true self.render = true if parent then self.render = false self.parent = parent table.insert(parent.children, self) end table.insert(dxObjects, self) return self end dxText.new = dxText.create;
  11. Hello Everyone .. In DxLibrary https://wiki.multitheftauto.com/wiki/Resource:DxLibrary I Want to make a Custom font that enabled on All Tools. To be More Clear .. In dxgui\elements\dx_text.lua local font1_segoeui = guiCreateFont("segoeui.ttf", 9) self.font = font1_segoeui The Default Settings Are .. self.font = "default" self.scale = 1 * 'self.scale' is the Size of the Text. * segoeui.ttf Added to META File. So what i'am doing is Editing the DxLibrary. When i tried that , the GUI Lagged & The Text didn't showed up. and no Error Given. am i missing something ? or the whole code is wrong ? ..
  12. Might be not what i'am talking about My friend. What i meant that If Player IsJailed, Then On Bindkey Function, Will Check if The Player is Jailed Using "SetElementData" & Will outputChatBox Message Say's "You Can't Use F1" , & Else will show the GUI Normally.
  13. VB, HTML, SQL, Little C# I Know that LUA is Depend's in How am i good at C Sharp.
  14. Here is My Edit's : xBindFunction_ = function () --function(player) if getElementData("F10") ~= true then outputChatBox("** You Can't Use The F10 ! ", root, 255, 0, 0, true) else guiSetVisible(GiveAdmin.Background ,not guiGetVisible(GiveAdmin.Background)); showCursor(guiGetVisible(GiveAdmin.Background)); end end bindKey(Key,"down",xBindFunction_); And On Player Is in Prison , then i Set: setElementData(getRandomPlayer(),"F10",true) Same for unJail Func: setElementData(getRandomPlayer(),"F10",nil) I'am shore that the Error is in "xBindFunction_" Function .. am i missing something there ?
  15. I am a Pro at 3 Programming Languages , So LUA Would not be So Unrecognized to me. I would not think that You Said that because my last Code make's a problem right ?
  16. @tosfera Maybe it didn't Checked if "isJailed" was "true" or "false" ? if ( getElementData ( thePlayer, "isJailed", "true" ) ) then return end is that might work ? or there is another way ? ..
  17. Here is what i tried (Server Side) ..: addEventHandler( "onClientKey", root, function(button,press) if button == "F1" then cancelEvent () outputChatBox("** You Can't Use The F1 ! ",root,255,0,0,true) return true end return false end )
  18. @tosfera Hold on please .. In the Second Part , You meant The Other Mod's Right ? So i Tried it .. here is the Code: xBindFunction_ = function () if ( getElementData ( thePlayer, "isJailed" ) ) then return end guiSetVisible(Project.Background ,not guiGetVisible(Project.Background)); showCursor(guiGetVisible(Project.Background)); end bindKey(Key,"down",xBindFunction_); Doesn't work.
  19. Greetings Everyone .. I'am looking for a way to Disable "F1 , F2, etc." for Source Player .. So Here is my idea .. While the Player is in Prison , he Can't Use F1, Or etc. just Like "toggleControl" , but with different Disabling. I Hope you got the idea .. So, Any help please ?
  20. Never mind .. Solution: local allowedVehicles = { [ 490 ] = true, [ 597 ] = true };
  21. Hold On Please .. It Doesn't Work with multiple Cars ! .. So this is works .. When i tried: local allowedVehicles = { [ 490 ] = true }; but when i tried this: local allowedVehicles = { [ 490, 597, etc. ] = true }; it didn't work !
  22. Didn't Noticed Thanks Every one ! Problem Solved.
  23. Great ! .. but i had a problem .. --------------------- --Key to open panel --------------------- open = false bindKey ( key, "down", function ( ) if ( vehicle ) then local allowedVehicles = { [ 599 ] = true }; if ( allowedVehicles [ getElementModel ( vehicle ) ] ) then if open == false then add() for k,v in ipairs(mywind) do guiSetVisible(v,true) guiSetAlpha(mywind[13],0.89999997615814) end showCursor(true) open = true else close() guiSetAlpha(mywind[13],0) end end end end ) So when i bindkey , it does nothing and no error giving ! That's strange .. because it was working with the last example: --------------------- --Key to open panel --------------------- open = false bindKey ( key, "down", function ( ) local vehicle = getPedOccupiedVehicle ( getLocalPlayer() ); if ( vehicle ) then if ( getElementModel ( vehicle ) == allowed_model ) then if open == false then add() for k,v in ipairs(mywind) do guiSetVisible(v,true) guiSetAlpha(mywind[13],0.89999997615814) end showCursor(true) open = true else close() guiSetAlpha(mywind[13],0) end end end end ) Weird problem ..
  24. ------------------- --Key For Open Panel ------------------- local key = "O" --------------------- --Key to Open Panel --------------------- open = false bindKey ( key, "down", function ( ) if open == false then add() for k,v in ipairs(mywind) do guiSetVisible(v,true) end showCursor(true) open = true else close() end end ) --------------------- --Close Panel --------------------- function close() for k,v in ipairs(mywind) do guiSetVisible(v,false) end showCursor(false) open = false setCameraTarget ( getLocalPlayer() ) end The Object if Window is "mywind[13]" ..
×
×
  • Create New...