Jump to content

مسأعدة في كود بسيط


#FeldMan

Recommended Posts

سلأم عليكم أبي لما ينتهي الشريط يجي أنميشن 

ذأ الي توصلت له من الويكي 

Client:

local screenWidth, screenHeight = guiGetScreenSize () -- Get the screen resolution (width and height)

function isElementMoving(theElement)
    if isElement (theElement) then
       return Vector3( getElementVelocity(theElement) ).length ~= 0
    end
    return false
 end







local screenWidth, screenHeight = guiGetScreenSize ()

local x,y = guiGetScreenSize()

local show = true

setElementData(localPlayer, "thirsty", 60)



function drawHud()

	if (show==true) then

		local thirsty = getElementData(localPlayer, "thirsty")


		dxDrawRectangle(683, 107, 196, 30, tocolor(0, 0, 0, 150))

		dxDrawRectangle(x-326, 34+80, thirsty*3, 17, tocolor(1, 96, 253, 255))

		dxDrawText("Fatigue", 745, 115, 825, 140, tocolor(255, 255, 255), 1, "default-bold", "center")





	end
end

addEventHandler("onClientRender", root, drawHud)


addEvent("onLocalPlayerStartsMoving")
addEvent("onLocalPlayerStopsMoving")
local localPlayerMoving = false
local deadSpeed = 0.01
setTimer(function ()
    local vx, vy, vz = getElementVelocity(localPlayer)
    local speed = (vx^2 + vy^2 + vz^2)^0.5
    if not localPlayerMoving and speed > deadSpeed then -- if starts moving
        localPlayerMoving = true
        triggerEvent("onLocalPlayerStartsMoving", localPlayer)
    elseif localPlayerMoving and speed <= deadSpeed then -- if stops moving
        localPlayerMoving = false
        triggerEvent("onLocalPlayerStopsMoving", localPlayer)
    end
end, 100, 0)

-- Usage example:

addEventHandler("onLocalPlayerStartsMoving", localPlayer, function()
---------------dxDrawRectangle(473, 109, 92, 27, tocolor(0, 0, 0, 150))
end)
addEventHandler("onLocalPlayerStopsMoving", localPlayer, function()
-----------------setElementData(localPlayer, "thirsty", 60)
end)

	


setTimer(function()
-------if not isElementMoving(localPlayer) then return end

    local under1 = getElementData(localPlayer, "thirsty")

  setElementData(localPlayer, "thirsty", under1-1)

end, 900, 0) 

addEventHandler("onClientRender", root, setTimer)





function die()

	local piageci = getElementData(localPlayer, "thirsty")





	if (piageci==0) then

		setElementData(localPlayer, "thirsty", 60)

                triggerServerEvent ("san1", localPlayer)
end
   end

addEventHandler("onClientElementDataChange", root, die)



-- Hide the hud when the resource is started

local components = { "weapon", "ammo", "health", "clock", "money", "breath", "armour", "wanted" }



addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()),

function ()

	for _, component in ipairs( components ) do

		setPlayerHudComponentVisible( component, false )

	end

end)



function fixhud()

	setPlayerHudComponentVisible( component, false )

end

addCommandHandler("fixhud", fixhud)

Server:

addEvent("san1", true)
addEventHandler ("san1",root,
function ( )
	if not getElementData(thePlayer, "sitting") then
		setPedAnimation(thePlayer, "ped", "seat_down", -1, false, false, false, false)
		setElementData(thePlayer, "sitting", true)
	else
		setPedAnimation(thePlayer)
		removeElementData(thePlayer, "sitting")
	end
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...