Jump to content

#\_oskar_/#

Members
  • Posts

    570
  • Joined

  • Last visited

  • Days Won

    4

Posts posted by #\_oskar_/#

  1. اكواد لملف lua 

    --usfull fun 
    executeBrowserJavascript_= executeBrowserJavascript 
    function executeBrowserJavascript (br,te)
    executeBrowserJavascript_(br,"document.getElementById('Call').innerHTML = '"  .. te .. "' ")
    end
    
    ------Browser Created-------
    addEventHandler("onClientBrowserCreated",resourceRoot,function ()
    loadBrowserURL(source, "http://mta/local/index.html")
    end)
    
    -----gui Create--------
    local sW, sH = guiGetScreenSize()
    window = guiCreateWindow(10, (sH - 186) / 2, 337, 186, "", false)
    guiSetVisible(window , false)
    local Name = guiGetBrowser(guiCreateBrowser(4, 23, 323, 34,true,true,false,window))
    local Money = guiGetBrowser(guiCreateBrowser(4, 57, 323, 34,true,true,false,window))
    
    ----- Send To HTML <span>
    function BrowserDocumentReady()
    executeBrowserJavascript (Name,'Yor Name ' ..getPlayerName (localPlayer))
    executeBrowserJavascript (Money,'Yor Money ' ..getPlayerMoney (localPlayer))
    end
    
    ----- open Window
    bindKey("F1","down",function ( )
    guiSetVisible(window,not guiGetVisible(window))
    showCursor(guiGetVisible(window))
    --- refresh
    BrowserDocumentReady()
    end)

    كود لملف HTML

    <span
    
     style=" color:green;  font-family: Arial, Helvetica, sans-serif;font-size : 15px"
    
     id="Call"
    
    span/>

    سويته لك بحيث يكون سهل عليك تفهمه بابسط طريقه

    • Like 1
  2. data,_add = { },addEventHandler
    function SColor(e,r,g,b)
     if getElementType(e) == 'gui-button' then guiSetProperty(e, 'NormalTextColour', string.format("%.2X%.2X%.2X%.2X",r,g,b,255)) end end
    dxDrawImage_ = dxDrawImage local dxDrawImage = function (...) local a = {...} 
    if isElement( a[1] ) and getElementType( a[1] ) == 'gui-button' and guiGetVisible (a[1]) then 
    data [ a[1] ] = true 
    local posX, posY = guiGetPosition ( a[1] , false )
    local width , Height = guiGetSize ( a[1] , false )
    dxDrawImage_ (posX , posY, width,Height,a[2], a[3],a[4],a[5], a[6] , a[7])
    local r, g, b = getColorFromString("#"..guiGetProperty(a[1], "NormalTextColour"))
    dxDrawText(guiGetText ( a[1] ) or tostring '',posX, posY, width + posX , Height + posY,SetTextcolor or tocolor(r, g, b,255),1,"default-bold","center","center",false,false,true)
    guiSetAlpha( a[1] , 0)
    end
    if not isElement( a[1] ) then return dxDrawImage_ (...) end
    end
    local function Enter()  
    if data [ source ] == true then SColor(source,0 ,255, 0) end end
    local function Leave() 
    if data [ source ] == true then SColor(source,255, 124,124) end end
    _add ( "onClientMouseEnter",resourceRoot,Enter) _add ( "onClientGUIMouseUp", resourceRoot,Enter)
    _add ( "onClientMouseLeave",resourceRoot,Leave) _add ( "onClientGUIMouseDown",resourceRoot,Leave)
    -----------------\\\\\\\\\\\\\\\\\\\\-----------------
    
    event = guiCreateButton(16, 20, 250, 40, "Take", false)
    guiSetVisible (event, false)
    
    addEventHandler ("onClientRender", root,
        function ()
             dxDrawImage(event ,'img/event.png', 0, 0, 0,tocolor(255, 255, 255, 255), true) -- attach to Button
            -- dxDrawImage(160, 200, 250, 40 ,'img/event.png', 0, 0, 0,tocolor(255, 255, 255, 255), true) -- dx Image
        end)
    
    bindKey( "k", "down",function( )
    		guiSetVisible( event , not  guiGetVisible( event ))
    		showCursor( guiGetVisible( event ))
    	end
    )

    try this

    • Thanks 1
  3. -- مود الايدي الي اسوي منه export
    
    local optimize = true -- Should the script be optimized? (if optimized, cannot be used client-side)
    local ids = {}
    
    function assignID()
    	for i=1,getMaxPlayers() do
    		if not ids[i] then
    			ids[i] = source
    			setElementData(source,"id",i,not optimize)
    			break
    		end
    	end
    end
    addEventHandler("onPlayerJoin",root,assignID)
    
    function startup()
    	for k, v in ipairs(getElementsByType("player")) do
    		local id = getElementData(v,"id")
    		if id then ids[id] = v end
    	end
    end
    addEventHandler("onResourceStart",resourceRoot,startup)
    
    function getPlayerID(player)
    	for k, v in ipairs(ids) do
    		if v == player then return k end
    	end
    end
    
    function freeID()
    	local id = getElementData(source,"id")
    	if not id then return end
    	ids[id] = nil
    end
    addEventHandler("onPlayerQuit",root,freeID)
    
    function getPlayerByID(id)
    	local player = ids[id]
    	return player or false
    end
    
    -- ابيه يجيب ايدي اللاعب
    -- Client
    function mid ( player, commandName )
    outputChatBox("Your ID IS"..getPlayerID(player), player, 0, 154, 255)
    end    
    addCommandHandler ( "myid", mid )
    

     

  4. function WalkingByAcl(ThePlayer,style,group)
    if isObjectInACLGroup("user."..getAccountName ( getPlayerAccount(ThePlayer)), aclGetGroup(group or "Admin")) then
    setPedWalkingStyle(ThePlayer,style or 0)
    end end
    ------------------
    addEventHandler("onPlayerLogin",root,function ()
    WalkingByAcl(source,69,'Admin') 
    end)
    
    local function startedResource()
    for key,ThePlayer in ipairs(getElementsByType("player")) do WalkingByAcl(ThePlayer,69,'Admin')  end
    end
    addEventHandler("onResourceStart",resourceRoot,startedResource)

     

  5. function changeWalkStyle(ThePlayer, command)
    if isObjectInACLGroup("user."..getAccountName ( getPlayerAccount(ThePlayer)), aclGetGroup("Admin")) then
    setPedWalkingStyle(ThePlayer,69)
    end 
    end
    addCommandHandler("WalkingStyle", changeWalkStyle)

     

  6. 4 hours ago, RandomRambo said:

    Create  an image and then create a button in front of image and on for example "K" hide it or show it

    You mean like that?

    function AttachDxToGuiElement( GUIElement , img )
    if ( guiGetVisible ( GUIElement ) ) then 
    local x, y = guiGetPosition ( GUIElement , false )
    local width , Height = guiGetSize ( GUIElement , false )
    dxDrawImage(x, y, width  , Height ,img, 0, 0, 0,SetImagecolor or tocolor(255, 0, 0, 255), true)
    dxDrawText(guiGetText ( GUIElement ) or tostring '',x, y, width + x , Height + y,SetTextcolor or tocolor(55,55,55,255),1,"default-bold","center","center",false,false,true)
    guiBringToFront ( GUIElement )
    guiSetAlpha ( GUIElement , 0)
    end
    end
    ------------------
    event = guiCreateButton(16, 20, 250, 40, "Take", false)
    
    addEventHandler ("onClientRender", root,
        function ()
             AttachDxToGuiElement( event ,'img/event.png' )
        end)
    
    bindKey( "k", "down",function( )
    		guiSetVisible( event , not  guiGetVisible( event ))
    		showCursor( guiGetVisible( event ))
    	end
    )

     

    • Thanks 1
  7. You have to add it with the window open

    this is an example 

    ??????

    window = guiCreateWindow(0.33, 0.35, 0.34, 0.31, "Test", true)
    
    VEHICLE_SETTINGS = false
    bindKey( "x", "down",  function()
    	if isPedInVehicle ( localPlayer ) and VEHICLE_SETTINGS == false then
    		guiSetVisible( window, true) showCursor( true )
    		VEHICLE_SETTINGS = true
    	else
                    guiSetVisible( window,false) showCursor( false )
    		VEHICLE_SETTINGS = false
    	end
    end)

     

  8. 35 minutes ago, yToPzz said:

    did not work : /

    He is working

    VEHICLE_SETTINGS = false
    bindKey( "x", "down",  function()
    if isPedInVehicle ( localPlayer ) and VEHICLE_SETTINGS == false then
    		openVehicleSettings()
    		VEHICLE_SETTINGS = true
    	else
    		closeVehicleSettings()
    		VEHICLE_SETTINGS = false
    	end
    end)

     

  9. 34 minutes ago, yToPzz said:

    thanks, but there is a problem if you open the panel without being in a vehicle the panel does not close is there a way to make the panel open only when in a car?

    if isPedInVehicle ( localPlayer ) and VEHICLE_SETTINGS == false then

     

  10. VEHICLE_SETTINGS = false
    addCommandHandler("steer", function()
    	if VEHICLE_SETTINGS == false then
    		openVehicleSettings()
    		VEHICLE_SETTINGS = true
    	else
    		closeVehicleSettings()
    		VEHICLE_SETTINGS = false
    	end
    end)
    
    bindKey( "x", "down",  "steer" )

    or

    VEHICLE_SETTINGS = false
    bindKey( "x", "down",  function()
    	if VEHICLE_SETTINGS == false then
    		openVehicleSettings()
    		VEHICLE_SETTINGS = true
    	else
    		closeVehicleSettings()
    		VEHICLE_SETTINGS = false
    	end
    end)

     

    • Thanks 1
  11. playerMarker = {}
    
    function handlePlayerMarker(hitElement)
    if getElementType(hitElement) == "player" then
    if isElement(playerMarker[hitElement]) then destroyElement(playerMarker[hitElement]) end
    end
    end
  12. 4 hours ago, Firespider said:
    Do you also need the client side?
     

    what do you want to do ?
    Because I see that all the proposed codes are working and there are no problems

×
×
  • Create New...