Jump to content

مساعدة


AliAlanzi

Recommended Posts

الحين انا عندي لوحه ابيها لمن اكتب الامر تفتح ببس لمن اكتب الامر ما تفتح اللوحه وش السبب؟

 

addEventHandler("onClientResourceStart", resourceRoot,
    function()
        window1 = guiCreateWindow(509, 175, 311, 452, "Revive Panel", false)
        guiWindowSetSizable(window1, false)
		        guiSetVisible( window1 ,false)
        gridlist = guiCreateGridList(13, 26, 288, 341, false, window1)
        guiGridListAddColumn(gridlist, "Players", 0.9)
        Button1 = guiCreateButton(17, 379, 139, 63, "Revive Player", false, window1)
        Button2 = guiCreateButton(166, 379, 135, 63, "Close", false, window1) 
        guiGridListClear(gridlist)		
    end
)
addCommandHandler('rp',
function ()
guiSetVisible(window1,not guiGetVisible(window1))
showCursor(guiGetVisible(window1))
changeGridListToPlayersAround ( gridlist, 1, 5 )
end
)
addEventHandler ( "onClientGUIClick",root,
function ()  
if (source == Button2) then
guiSetVisible( window1 ,false)
showCursor(false)
   end
end
)
addEventHandler ( "onClientGUIClick",root,
function ()  
if (source == Button1) then
guiSetVisible( window1 ,false)
showCursor(false)
     setElementHealth ( player,100)
   end
end
)
function isElementInRange(ele, x, y, z, range)
	   if isElement(ele) and type(x) == "number" and type(y) == "number" and type(z) == "number" and type(range) == "number" then
		  return getDistanceBetweenPoints3D(x, y, z, getElementPosition(ele)) <= range -- returns true if it the range of the element to the main point is smaller than (or as big as) the maximum range.
	   end
	   return false
	end
	
	function changeGridListToPlayersAround ( gridlist, column, range )
  		if type ( column ) == 'number' and type ( range ) == 'number' and getElementType ( gridlist ) == 'gui-gridlist' then
    	guiGridListClear ( gridlist )
          for i,v in ipairs ( getElementsByType ( 'player' ) ) do
      		 if ( v == getLocalPlayer ( ) ) then
                return
        	end
              local x,y,z = getElementPosition ( localPlayer )
                  if isElementInRange ( v, x, y, z, range ) then
                      local row = guiGridListAddRow ( gridlist )
                      guiGridListSetItemText ( gridlist, row, column, getPlayerName ( v ), false, false )
				 end
  		end
		return true
		else
		return false
	end
end


function refreshgirdlist ()
       for _,v in ipairs ( getElementsByType ( "player" ) ) do 
       x,y,z = getElementPosition(localPlayer)
       x1,y1,z1 = getElementPosition(v)
       Distance = getDistanceBetweenPoints3D (x,y,z,x1,y1,z1)
       if Distance <= 50 then 
 
 end 

 

و انا ابي اللاعبين القريبين من فقط

اغير number

  if isElement(ele) and type(x) == "number" and type(y) == "number" and type(z) == "number" and type(range) == "number" then

 

Link to comment
-- Client side

addEventHandler("onClientResourceStart", resourceRoot,
    function()
        window1 = guiCreateWindow(509, 175, 311, 452, "Revive Panel", false)
        guiWindowSetSizable(window1, false)
		        guiSetVisible( window1 ,false)
        gridlist = guiCreateGridList(13, 26, 288, 341, false, window1)
        guiGridListAddColumn(gridlist, "Players", 0.9)
        Button1 = guiCreateButton(17, 379, 139, 63, "Revive Player", false, window1)
        Button2 = guiCreateButton(166, 379, 135, 63, "Close", false, window1) 
        guiGridListClear(gridlist)		
    end
)

addCommandHandler('rp',
function ()
guiSetVisible(window1,not guiGetVisible(window1))
showCursor(guiGetVisible(window1))
changeGridListToPlayersAround ( gridlist, 1, 5 )
end
)

-- Close button
addEventHandler ( "onClientGUIClick",root,
function ()  
if (source == Button2) then
guiSetVisible( window1 ,false)
showCursor(false)
   end
end
)

-- Health button
addEventHandler ( "onClientGUIClick", resourceRoot,
function ()  
if (source == Button1) then
	local gRow, gColumn =( guiGridListGetSelectedItem ( gridlist ) )
	if gRow >= 0 then
    local PlayerName = guiGridListGetSelectedItemText ( gridlist )
	local target = getPlayerFromName(PlayerName)
	triggerServerEvent("onPlayerHealed", resourceRoot, target)
	guiSetVisible( window1 ,false)
	showCursor(false)
	else
	outputChatBox("Select a player to heal!", 0, 255, 0)
   end
   end
end)



-- [[ Useful functions ]] --

function guiGridListGetSelectedItemText ( gridList, column )
    local item = guiGridListGetSelectedItem ( gridList )
    
    if item then
        return guiGridListGetItemText ( gridList, item, column or 1 )
    end

    return false
end

function isElementInRange(ele, x, y, z, range)
	if isElement(ele) and type(x) == "number" and type(y) == "number" and type(z) == "number" and type(range) == "number" then
	  return getDistanceBetweenPoints3D(x, y, z, getElementPosition(ele)) <= range -- returns true if it the range of the element to the main point is smaller than (or as big as) the maximum range.
	end
	return false
end
	
function changeGridListToPlayersAround ( gridlist, column, range )
  	if type ( column ) == 'number' and type ( range ) == 'number' and getElementType ( gridlist ) == 'gui-gridlist' then
    	guiGridListClear ( gridlist )
        for i,v in ipairs ( getElementsByType ( 'player' ) ) do
      		 if ( v ~= localPlayer ) then
              local x, y, z = getElementPosition ( localPlayer )
                 if isElementInRange ( v, x, y, z, range ) then
                    local row = guiGridListAddRow ( gridlist )
					return guiGridListSetItemText ( gridlist, row, column, getPlayerName ( v ), false, false )
				 end
			 end
  		end
	else
	return false
	end
end


function refreshgirdlist ()
    for _,v in ipairs ( getElementsByType ( "player" ) ) do 
    x,y,z = getElementPosition(localPlayer)
    x1,y1,z1 = getElementPosition(v)
    Distance = getDistanceBetweenPoints3D (x,y,z,x1,y1,z1)
    if Distance <= 50 then 
	end
 end
end
 
-- Server side
addEvent("onPlayerHealed", true)
addEventHandler("onPlayerHealed", resourceRoot,
function (target)
  if isElement (target) then
	outputChatBox( string.gsub(getPlayerName(target), "#%x%x%x%x%x%x", "") .. " has been healed.", client, 0, 255, 0, true)
	setElementHealth( target, 100 )
  end
end)

ما تأكدت من سالفة المسافة لكن المفروض أن حركتك تضبط زي ماسويتها أنت, وبالنسبه للوحة تفتح عندي بدون مشاكل.

Edited by King12
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...