Jump to content

[Help] in Grid List


#AL-J7EEEM

Recommended Posts

Hi, I have a problem with my script. The problem is that I have created a GirdList that shows the accounts that are registered and the specific data. But now nothing appears and the window does not open.
-Server

Table = {
	Commands = { 
		WindowOpen = 'dmanager' -- أمر فتح اللوحة
	} , 
	Accounts = { -- أسماء حساباتك
		'goda' ,
		'' ,
		'' ,
		'' ,
		''
	} ,
}

addCommandHandler ( Table.Commands.WindowOpen ,
	function ( Player )
		local Account = getPlayerAccount ( Player )
		if ( isGuestAccount ( Account ) ) then
			return 
		end
		local Name = getAccountName ( Account )
		for _ , v in ipairs ( Table.Accounts ) do
			if ( Name == v ) then 
				triggerClientEvent ( Player , 'OpenWnd' , Player )
				outputChatBox ( '*Welcome Manager' , Player )
			end
		end 
	end 
)







addEvent( "showchatdata",true )
addEventHandler( "showchatdata",root,
	function()
	for i,player in ipairs(getElementsByType("player")) do
			local data = getElementData( player,'playerDiamond' )
			local acc  =getPlayerAccount( player )
			if not isGuestAccount( acc ) then
        if data then
				outputChatBox('#FFFFFFAccount#FF0000  ['..getAccountName(acc)..']  #00FFFFDiamond#FFFFFF '..data..' .',root,255,255,255,true)
			else
				outputChatBox('Player is not logged in !',root,255,0,0,true)
          end
		end
	end
end)

addEvent ( 'onTriggerGetAccounts' , true )
addEventHandler ( 'onTriggerGetAccounts' , root , 
  function ( )
    local Accounts = { }
    for _ , v in ipairs ( getAccounts ) do
      local Name = getAccountName ( v )
      local Serial = getAccountsSerial ( Name ) 
      table.insert ( Accounts , { Name , Serial } ) 
      triggerClientEvent ( source , 'onTriggerGiveAccount' , source , Accounts ) 
    end 
  end 
)

-----------------------------------------------


function onStart (	)
players = getElementsByType('player')
for index,values in ipairs ( players ) do 
setElementData ( values , 'playerDiamond' , getElementData ( values , 'playerDiamond' ) or 0 )
end
end
addEventHandler('onResourceStart',resourceRoot,onStart)

function getPlayerDiamond ( player ) 
if ( getElementType ( player ) ~= 'player' ) then return false end 
return getElementData ( player , 'playerDiamond' ) or 0 
end

function takePlayerDiamond ( player , amount )
if ( getElementType ( player ) ~= 'player' and type ( amount ) ~= 'number' ) then 
return false 
end
setElementData ( player , 'playerDiamond' , getPlayerDiamond ( player ) - amount or 0 ) 
end

function setPlayerDiamond ( player , amount )
if ( getElementType ( player ) ~= 'player' and type ( amount ) ~= 'number' ) then 
return false 
end
setElementData ( player , 'playerDiamond' , getPlayerDiamond ( player ) + amount or 0 )
end
---------------
addEventHandler('onPlayerJoin',root, 
function (	)
setElementData ( source , 'playerDiamond' , 0)
end
)

addEventHandler('onPlayerQuit',root,
function (	)
local acc = getPlayerAccount ( source ) 
if ( not isGuestAccount ( acc ) ) then 
setAccountData ( acc , 'Save:playerDiamond' , getElementData ( source , 'playerDiamond' ) or 0 )
end
end
)

addEventHandler('onPlayerLogin',root, 
function (_,acc)
local accD = getAccountData ( acc , 'Save:playerDiamond' ) 
if ( accD ) then 
setElementData ( source , 'Diamond' , accD )
else
setElementData ( source , 'Diamond' , 0)
end
end
)
-------------------------
addEvent('onSetDiamond',true)
addEventHandler('onSetDiamond',root,
function ( player , di )
if ( getAccountName ( player ) ) then 
if ( tonumber ( di ) ) then
setPlayerDiamond ( getAccountName ( player ) , tonumber ( di ) or 0 )
setAccountData ( getPlayerAccount(getAccountName(player))  , 'Save:playerDiamond' , getElementData ( getAccountName(player) , 'playerDiamond' ) )
outputChatBox('#ffffff[ #f77f00Diamond-System #ffffff] #f77f00 You Have Been Give Diamond',source,255,255,255,true)
else
outputChatBox('#ffffff[ #f77f00Diamond-System #ffffff] #f77f00 Please Write Number only',source,255,255,255,true)
end
end
end
)

addEvent('onTakeDiamond',true)
addEventHandler('onTakeDiamond',root,
function ( player , di )
if ( getAccountName ( player ) ) then 
if ( tonumber ( di ) ) then  
if ( getPlayerDiamond ( getAccountName ( player ) ) > 1 ) then
setAccountData ( getPlayerAccount(getAccountName(player)) , 'Save:playerDiamond' , getElementData ( getAccountName(player) , 'playerDiamond' ) )
takePlayerDiamond ( getAccountName ( player ) , tonumber ( di ) or 0 )
outputChatBox('#ffffff[ #f77f00Diamond-System #ffffff] #f77f00 You Have Been Take Diamond',source,255,255,255,true)
else
outputChatBox('#ffffff[ #f77f00Diamond-System #ffffff] #f77f00 This Player Dont Have Diamond ',source,255,255,255,true)
end
else
outputChatBox('#ffffff[ #f77f00Diamond-System #ffffff] #f77f00 Please Write Number only',source,255,255,255,true)
end
end
end
)

addEventHandler('onPlayerLogout',root, function (	)
setElementData ( source , 'playerDiamond' , 0)
end)

-Client
 

GUIEditor = {
    gridlist = {},
    window = {},
    staticimage = {}
}
addEventHandler("onClientResourceStart", resourceRoot,
    function()
        EVOD = guiCreateWindow(147, 86, 535, 417, "[Diamond Manager] [V1]", false)
        guiWindowSetSizable(EVOD, false)
        guiSetAlpha(EVOD, 1.00)
		guiSetVisible(EVOD, false)
        List = guiCreateGridList(43, 49, 238, 332, false, EVOD)
        GUIEditor.staticimage[1] = guiCreateStaticImage(20, 33, 280, 16, "IMG1.png", false, EVOD)
        column1(List, "Accounts", 0.3)
        column2(List, "Diamonds", 0.3)
        column3(List, "Serial", 0.3)
        GUIEditor.staticimage[2] = guiCreateStaticImage(281, 49, 19, 332, "IMG1.png", false, EVOD)
        GUIEditor.staticimage[3] = guiCreateStaticImage(20, 49, 19, 332, "IMG1.png", false, EVOD)
        GUIEditor.staticimage[4] = guiCreateStaticImage(20, 381, 280, 16, "IMG1.png", false, EVOD)
        set = guiCreateButton(435, 168, 87, 29, "Give", false, EVOD)
        guiSetProperty(set, "NormalTextColour", "FF04FAE6")
        take = guiCreateButton(435, 203, 87, 29, "Take", false, EVOD)
        guiSetProperty(take, "NormalTextColour", "FF04FAE6")

		guiEditSetReadOnly(account, true) 
		guiEditSetReadOnly(serial, true)  
		guiEditSetReadOnly(diamond, true)
		
		for i,v in ipairs ( getElementsByType('player') ) do 
		local row = guiGridListAddRow ( List ) 

        addD = guiCreateEdit(362, 169, 68, 28, "", false, EVOD)
        takeT = guiCreateEdit(362, 203, 68, 28, "", false, EVOD)
        account = guiCreateEdit(374, 52, 138, 23, "Account Name", false, EVOD)
        serial = guiCreateEdit(374, 80, 138, 23, "Serial", false, EVOD)
        diamond = guiCreateEdit(374, 108, 138, 23, "Daimond", false, EVOD)
		GUIEditor.staticimage[5] = guiCreateStaticImage(334, 275, 188, 132, "waitIcon.png", false, EVOD)
        GUIEditor.button[1] = guiCreateButton(329, 242, 193, 25, "Show All Diamond In Chat", false, EVOD)
        guiSetProperty(GUIEditor.button[1], "NormalTextColour", "FFFA6603")		
    end
	end
)


------GetDataAccountSerial------
  function getServerAccounts ( )
  triggerServerEvent ( 'onTriggerGetAccounts' , localPlayer )
end

	function getAccounta ( Accounts ) 
	guiGridListClear ( List )
	for _ , v in ipairs ( player ) do
    Row = guiGridListAddRow ( List )
    guiGridListSetItemText ( List, Row, column1, v.Name , false, false )
	guiGridListSetItemText( List, Row, column2, getElementData ( player, "playerDiamond" ),false,false)
    guiGridListSetItemText ( List, Row, column3, v.Serial , false, false )
  end
end
addEvent ( 'onTriggerGiveAccount' , true )
addEvdntHandler ( 'onTriggerGiveAccount' , root , getAccounta )
--------------------------------------
---OnClick---
-----ShowDiamond---
addEventHandler('onClientGUIClick',root,function()
  if source==show then 
        triggerServerEvent('showchatdata',localPlayer)
        
  end
  end)
---------------
-----Take&GiveDiamond------
addEventHandler('onClientGUIClick',root, function (	)
if ( source == set ) then 
if ( guiGridListGetSelectedItem ( List ) == -1 and guiGetText ( addD ) == '' ) then 
return outputChatBox('#ffffff[ #f77f00Diamond-System #ffffff] #f77f00 Please Select player or write text',255,255,255,true) end 
triggerServerEvent('onSetDiamond',localPlayer,guiGridListGetItemText(List,guiGridListGetSelectedItem(List),1),guiGetText(addD))
elseif ( source == take ) then
if ( guiGridListGetSelectedItem ( List ) == -1 and guiGetText ( takeT ) == '' ) then 
return outputChatBox('#ffffff[ #f77f00Diamond-System #ffffff] #f77f00 Please Select player or write text',255,255,255,true) end 
triggerServerEvent('onTakeDiamond',localPlayer,guiGridListGetItemText(List,guiGridListGetSelectedItem(List),1),guiGetText(takeT))
end
end
)
-----------------------------
----------CloseWindow------------

---------------------------------
-------EndOnClick-----------
---------Open-----------
function setGUIvisible ()
	local GUIvisible = ( not guiGetVisible ( EVOD ) )
	guiSetVisible ( EVOD, GUIvisible )
	showCursor ( GUIvisible )
getServerAccounts ( )
end

addEvent( "OpenWnd", true )
addEventHandler ( "OpenWnd", root, setGUIvisible )
------------------

 

Link to comment

can u try this ?

addCommandHandler ( Table.Commands.WindowOpen ,
	function ( Player )
		local Account = getPlayerAccount ( Player )
		if ( isGuestAccount ( Account ) ) then
			return 
		end
		local Name = getAccountName ( Account )
		for _ , v in pairs ( Table.Accounts ) do
			if ( Name == v ) then 
				triggerClientEvent ( Player , 'OpenWnd' , Player )
				outputChatBox ( '*Welcome Manager' , Player )
			end
		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...