Sign in to follow this  
kevincouto6

Help me

Recommended Posts

Could anyone help me, use Bind key K to open and Close the Window

addEventHandler("onClientResourceStart", resourceRoot,function()
weaponWindow = guiCreateWindow(1621, 398, 256, 382, "weapon")
guiWindowSetSizable(weaponWindow, false)
weaponGrid = guiCreateGridList(16, 30, 226, 337,weaponWindow)
guiGridListAddColumn(weaponGrid, "Inventory", 0.9)
guiSetVisible (weaponWindow, false )
guiSetVisible (weaponGrid, false )
bindKey ( "k","down" , showGUI)
toggleControl ( "next_weapon", false) 
toggleControl ( "previous_weapon", false) 
guiGridListSetSortingEnabled ( weaponGrid, false )
end
)
addEventHandler("onClientResourceStop", resourceRoot,function()
toggleControl ( "next_weapon", true) 
toggleControl ( "previous_weapon", true) 
end
)
function showGUI()
if guiGetVisible ( weaponWindow )==false then
guiSetVisible (weaponWindow, true )
guiSetVisible (weaponGrid, true )
showCursor(true)
else
guiSetVisible (weaponWindow, false )
guiSetVisible (weaponGrid, false )
showCursor(false)
guiGridListClear ( weaponGrid )
end      
end
function showGUI2()
if guiGetVisible ( weaponWindow )==false then
guiSetVisible (weaponWindow, false )
guiSetVisible (weaponGrid, false )
showCursor(false)
else
guiSetVisible (weaponWindow, false )
guiSetVisible (weaponGrid, false )
showCursor(false)
guiGridListClear ( weaponGrid )
end      
end

function refreshWeapons()
x = 0
for i=0,11,1 do 
if (getWeaponNameFromID(getPedWeapon ( localPlayer, i))) ~= "Fist" or i==0 then
--outputChatBox(getWeaponNameFromID(getPedWeapon ( localPlayer, i)))
guiGridListAddRow(weaponGrid)
guiGridListSetItemText(weaponGrid, x, 1, getWeaponNameFromID(getPedWeapon ( localPlayer, i)), false, false)   
x=x+1
end
end
if (guiGridListGetSelectedItem ( weaponGrid ) ) ~= -1 then
setPedWeaponSlot ( localPlayer, getSlotFromWeapon(getWeaponIDFromName(guiGridListGetItemText ( weaponGrid, guiGridListGetSelectedItem ( weaponGrid ) ))) )
end
end
addEventHandler("onClientRender", root,refreshWeapons)

 

Edited by kevincouto6

Share this post


Link to post
local x,y = guiGetScreenSize()
addEventHandler("onClientResourceStart", resourceRoot,function()
	weaponWindow = guiCreateWindow((x/2)-(256/2),(y/2)-(398/2), 256, 382, "weapon",false)
	guiWindowSetSizable(weaponWindow, false)
	weaponGrid = guiCreateGridList(16, 30, 226, 337,false,weaponWindow)
	guiGridListAddColumn(weaponGrid, "Inventory", 0.9)
	guiSetVisible (weaponWindow, false )
	toggleControl ( "next_weapon", false) 
	toggleControl ( "previous_weapon", false) 
	guiGridListSetSortingEnabled ( weaponGrid, false )
	addEventHandler("onClientGUIDoubleClick",weaponWindow,selectWeapon)
end)

addEventHandler("onClientResourceStop", resourceRoot,function()
	toggleControl ( "next_weapon", true) 
	toggleControl ( "previous_weapon", true) 
end)

bindKey("k","down",
function()
	guiSetVisible(weaponWindow,not guiGetVisible(weaponWindow))
	showCursor(guiGetVisible(weaponWindow))
	refreshWeapons()
end)


function refreshWeapons()
	guiGridListClear(weaponGrid)
	for i=1,9 do 
		local weapon = getPedWeapon(localPlayer,i)
		if weapon and weapon ~= 0 then
			guiGridListAddRow(weaponGrid)
			guiGridListSetItemText(weaponGrid,guiGridListAddRow(weaponGrid),1,getWeaponNameFromID(weapon),false,false)
		end
	end
end

function selectWeapon()
	local row,col = guiGridListGetSelectedItem(weaponGrid)
	local text = guiGridListGetItemText(weaponGrid,row,col)
	if text ~= "" then
		setPedWeaponSlot(localPlayer,getSlotFromWeapon(getWeaponIDFromName(text)))
	end
end

 

Share this post


Link to post

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.