Jump to content

مشكله x


Jw8.

Recommended Posts

admins = 'C158E34B81CDD38BDA0CB0650E6EC692' -- لاتنسى تعدل الى السريال الخاص فيك

gold_settings = { 
	cars={ 455, 505, 512 },
	weapons={ 30, 45, 31 },
	money={ 10000, 13000, 30000 },
};

silver_settings = { 
	cars={ 455, 505, 512 },
	weapons={ 30, 45, 31 },
	money={ 10000, 13000, 30000 },
};

wooden_settings = { 
	cars={ 455, 505, 512 },
	weapons={ 30, 45, 31 },
	money={ 10000, 13000, 30000 },
};


GUIEditor = {
    gridlist = {},
    window = {},
    button = {},
    label = {}
}


addEventHandler("onClientResourceStart", resourceRoot,
    function()
        GUIEditor.window[1] = guiCreateWindow(0.35, 0.35, 0.32, 0.42, "Packages", true)
        guiWindowSetMovable(GUIEditor.window[1], false)
        guiWindowSetSizable(GUIEditor.window[1], false)
        guiSetAlpha(GUIEditor.window[1], 1.00)
        guiSetProperty(GUIEditor.window[1], "CaptionColour", "FF059140")
		guiSetVisible(GUIEditor.window[1], false)
		
        GUIEditor.label[1] = guiCreateLabel(0.01, 0.82, 0.36, 0.06, "Wooden package : 0", true, GUIEditor.window[1])
        guiLabelSetColor(GUIEditor.label[1], 195, 91, 59)
        GUIEditor.label[2] = guiCreateLabel(0.01, 0.88, 0.36, 0.06, "Silver package : 0", true, GUIEditor.window[1])
        guiLabelSetColor(GUIEditor.label[2], 154, 158, 156)
        GUIEditor.label[3] = guiCreateLabel(0.01, 0.93, 0.36, 0.06, "Golden package : 0", true, GUIEditor.window[1])
        guiLabelSetColor(GUIEditor.label[3], 250, 200, 79)
        GUIEditor.gridlist[1] = guiCreateGridList(0.01, 0.05, 0.58, 0.75, true, GUIEditor.window[1])
        guiGridListAddColumn(GUIEditor.gridlist[1], "Package", 0.9)
        GUIEditor.button[1] = guiCreateButton(0.61, 0.30, 0.38, 0.08, "توزيع البكجات | للأدمنية فقط", true, GUIEditor.window[1])
        guiSetProperty(GUIEditor.button[1], "NormalTextColour", "FFF5AB53")
		guiSetEnabled(GUIEditor.button[1], false)
        GUIEditor.label[4] = guiCreateLabel(0.66, 0.91, 0.31, 0.06, "Created by NX_CI & Ad[N]a[N]e", true, GUIEditor.window[1])
        guiLabelSetColor(GUIEditor.label[4], 17, 48, 138)
        GUIEditor.button[2] = guiCreateButton(0.61, 0.18, 0.38, 0.08, "فتح البكج", true, GUIEditor.window[1])
        guiSetProperty(GUIEditor.button[2], "NormalTextColour", "FF199A00")
        GUIEditor.button[3] = guiCreateButton(0.61, 0.70, 0.38, 0.08, "إغلاق", true, GUIEditor.window[1])
        guiSetFont(GUIEditor.button[3], "default-bold-small")
        guiSetProperty(GUIEditor.button[3], "NormalTextColour", "FF990000")
		

		--لوحة التوزيع
		
        GUIEditor.window[2] = guiCreateWindow(0.68, 0.41, 0.17, 0.33, "التوزيع", true)
        guiWindowSetMovable(GUIEditor.window[2], false)
        guiWindowSetSizable(GUIEditor.window[2], false)
        guiSetProperty(GUIEditor.window[2], "CaptionColour", "FF2BC901")
		guiSetVisible(GUIEditor.window[2], false)
		
        GUIEditor.gridlist[2] = guiCreateGridList(109, 24, 202, 315, false, GUIEditor.window[2])
        guiGridListAddColumn(GUIEditor.gridlist[2], "اللاعبون", 0.9)
        GUIEditor.button[5] = guiCreateButton(9, 178, 90, 27, "Silver توزيع بكج", false, GUIEditor.window[2])
        guiSetProperty(GUIEditor.button[5], "NormalTextColour", "FFD7D2D4")
        GUIEditor.button[6] = guiCreateButton(9, 211, 90, 27, "Gold توزيع بكج", false, GUIEditor.window[2])
        guiSetProperty(GUIEditor.button[6], "NormalTextColour", "FFFFD647")
        GUIEditor.button[7] = guiCreateButton(9, 145, 94, 27, "Wooden توزيع بكج", false, GUIEditor.window[2])
        guiSetProperty(GUIEditor.button[7], "NormalTextColour", "FFF76D11")
        GUIEditor.button[8] = guiCreateButton(12, 301, 29, 33, "X", false, GUIEditor.window[2])
        guiSetProperty(GUIEditor.button[8], "NormalTextColour", "FFCB0000")    
		
    end
)





windowVisible=function()
	
	if guiGetVisible(GUIEditor.window[1]) then
	
		guiSetVisible( GUIEditor.window[1], false )
		
		showCursor( false )
		
		guiSetEnabled(GUIEditor.button[1], false)
		
		if timer and isTimer(timer) then
		
			killTimer(timer)
			
		end
		
	else
	
		guiSetVisible( GUIEditor.window[1], true )
		
		showCursor( true )
	
		guiGridListClear(GUIEditor.gridlist[1])
		
		refreshPackageGridList()
		
		if getPlayerSerial(localPlayer) == admins then
		
			guiSetEnabled(GUIEditor.button[1], true)
			
		end
		
		timer = setTimer(
			
			function()
			
				setLabelPackagesCount()
				refreshPackageGridList()
				
			end,
			
		5000, 0)
		
	end
	
	if guiGetVisible(GUIEditor.window[2]) then
	
		guiSetVisible(GUIEditor.window[2], false);
		
		guiGridListClear(GUIEditor.gridlist[2])
		
	end
	
end







bindKey('F7', 'down', windowVisible)






function setLabelPackagesCount()

	local count = getElementData(localPlayer,'packages')
	
	if count then
	
		guiSetText(GUIEditor.label[1],"Wooden package : "..tostring(count.wooden))
	
		guiSetText(GUIEditor.label[2],"Silver package : "..tostring(count.silver))
	
		guiSetText(GUIEditor.label[3],"Golden package : "..tostring(count.gold))
		
	end
	
end







function getPlayerPackages( player )

	if isElement(player) then
	
		if getElementType(player) == 'player' then
		
			local playerPacks = getElementData( player, 'packages')
			
			if playerPacks and type(playerPacks)=='table' then
			
				for k, v in ipairs (playerPacks) do
					
					return v
					
				end
				
			else 
			
				return false
				
			end
			
		else
			
			return nil
			
		end
		
	else
		
		return nil
		
	end
	
end





function refreshPackageGridList()

	local clear=guiGridListClear(GUIEditor.gridlist[1])
	
	if clear then
	
		local packs = getElementData(localPlayer, 'packages')
		
		if packs then
		
			if packs.wooden >= 1 or packs.silver >= 1 or packs.gold >= 1 then
			
				if packs then
		
					for i = 1, packs.wooden do
			
						local row = guiGridListAddRow ( GUIEditor.gridlist[1], i )
			
						guiGridListSetItemText ( GUIEditor.gridlist[1], row, 1, 'Wooden', false, false )
				
						guiGridListSetItemColor ( GUIEditor.gridlist[1], row, 1, 232, 108, 0 )
				
					end
			
					for i = 1, packs.silver do
			
						local row = guiGridListAddRow ( GUIEditor.gridlist[1], i )
			
						guiGridListSetItemText ( GUIEditor.gridlist[1], row, 1, 'Silver', false, false )
				
						guiGridListSetItemColor ( GUIEditor.gridlist[1], row, 1, 155, 155, 155 )
				
					end
			
					for i = 1, packs.gold do
			
						local row = guiGridListAddRow ( GUIEditor.gridlist[1], i )
			
						guiGridListSetItemText ( GUIEditor.gridlist[1], row, 1, 'Gold', false, false )
				
						guiGridListSetItemColor ( GUIEditor.gridlist[1], row, 1, 238, 238, 123 )
				
					end
			
				end
		
			end
		
		end
		
	end

end







addEventHandler("onClientGUIClick", root,	
	
	function()
	
		if source == GUIEditor.button[1] then
		
			local status=guiGetVisible(GUIEditor.window[2]);
			
			guiSetVisible(GUIEditor.window[2],not status);
			
			local clear = guiGridListClear(GUIEditor.gridlist[2]);
			
			if clear then
			
				guiGridListAddPlayers();
				
			end
			
		elseif source == GUIEditor.button[8] then
		
			guiSetVisible(GUIEditor.window[2],false)
			
			guiGridListClear(GUIEditor.gridlist[2])
			
		elseif source == GUIEditor.button[7] then
			
			row , col = guiGridListGetSelectedItem ( GUIEditor.gridlist[2] )
			
			if row >= 0 then
			
				local playerName = guiGridListGetItemData(GUIEditor.gridlist[2], row, 1)

				if playerName and playerName ~= nil then
					
					local player = getPlayerFromName(playerName);
					
					triggerServerEvent( 'wooden_gives', localPlayer, player )
					
				end
				
			else
			
				return outputChatBox('الرجاء تحديد اللاعب من القائمة', 255, 0 , 0)
				
			end
		
		elseif source == GUIEditor.button[5] then
			
			row , col = guiGridListGetSelectedItem ( GUIEditor.gridlist[2] )
			
			if row >= 0 then
			
				local playerName = guiGridListGetItemData(GUIEditor.gridlist[2], row, 1)

				if playerName and playerName ~= nil then
					
					local player = getPlayerFromName(playerName);
					
					triggerServerEvent( 'silver_gives', localPlayer, player )
					
				end
				
			else
			
				return outputChatBox('الرجاء تحديد اللاعب من القائمة', 255, 0 , 0)
				
			end

		elseif source == GUIEditor.button[6] then
			
			row , col = guiGridListGetSelectedItem ( GUIEditor.gridlist[2] )
			
			if row >= 0 then
			
				local playerName = guiGridListGetItemData(GUIEditor.gridlist[2], row, 1)

				if playerName and playerName ~= nil then
					
					local player = getPlayerFromName(playerName);
					
					triggerServerEvent( 'gold_gives', localPlayer, player )
					
				end
				
			else
			
				return outputChatBox('الرجاء تحديد اللاعب من القائمة', 255, 0 , 0)
				
			end
		elseif source == GUIEditor.button[3] then
		
			windowVisible()
		
		elseif source == GUIEditor.button[2] then
			
			guiSetEnabled(GUIEditor.button[2],false)
			
			setTimer(guiSetEnabled, 5000, 1, GUIEditor.button[2],true)
			
			local row, col = guiGridListGetSelectedItem(GUIEditor.gridlist[1]);
			
			if row >= 0 then
			
				local package = guiGridListGetItemText( GUIEditor.gridlist[1], row, 1 );
				
				if package then
				
					if package == "Wooden" or package == "Silver" or package == "Gold" then
					
						triggerServerEvent("givePlayerGift", localPlayer, package);
						
					end
					
				end
				
			else
			
				return outputChatBox("الرجاء إختيار البكج *", 255,0,0);
				
			end
			
		end
		
	end
	
)








function guiGridListAddPlayers()

	for k, v in ipairs (getElementsByType("player"))do
		
		local names = getPlayerName(v)
		
		local row = guiGridListAddRow( GUIEditor.gridlist[2] )
		
		local text = guiGridListSetItemText( GUIEditor.gridlist[2], row, 1, string.gsub(names,'#%x%x%x%x%x%x',''), false, false )
		
		local data = guiGridListSetItemData(GUIEditor.gridlist[2], row, 1, names)
		
		guiGridListSetItemColor(GUIEditor.gridlist[2], row, 1, 255,255,0)
		
	end
	
end

 

 

 

-- Server

 

local packs_kills = { 
	
	['Wooden']=30,
	['Silver']=40,
	['Gold']=50,
	
}


for k, v in ipairs ( getElementsByType('player') ) do

	removeElementData(v,"packages")
	
end



function calcKill( _, killer )

	local data = getElementData( killer , 'kills' );
	
	if data and type(data) == "number" and data ~= 0 then
		
		if data ~= packs_kills['Gold'] and data ~= packs_kills['Silver'] and data ~= packs_kills['Wooden'] then
		
			setElementData( killer, 'kills', data+1 )
		
		elseif data == packs_kills['Wooden'] then
		
			setElementData( killer, 'kills', data+1 )
			
			givePlayerPackage( killer, 'Wooden' )
			
		elseif data == packs_kills['Silver'] then
		
			setElementData( killer, 'kills', data+1 )
			
			givePlayerPackage( killer, 'Silver' )
			
		elseif data == packs_kills['Gold'] then
	
			setElementData( killer, 'kills', 1 )
			
			givePlayerPackage( killer, 'Gold' )
	
		end
		
	else
	
		setElementData( killer, 'kills', 1 )
		
	end

end





addEventHandler('onPlayerWasted', root, calcKill)







function givePlayerPackage( player , package )

	if player and package then
	
		if isElement( player ) then
		
			if type( package ) == 'string' then
			
				if package == 'Wooden' or package == 'Silver' or package == 'Gold' then
					
					local packs = getElementData( player, 'packages' )
					
					if type(packs) == 'table' then
							
						local Wooden=packs.wooden
							
						local Silver=packs.silver
							
						local Gold=packs.gold
							
						if Wooden and Silver and Gold then
							
							if package == 'Wooden' then
						
								setElementData(player,'packages',{wooden=Wooden+1, silver=Silver, gold=Gold})
								
								outputChatBox("You got a Wooden package",player)
								
							elseif package == 'Silver' then
							
								setElementData(player,'packages',{wooden=Wooden, silver=Silver+1, gold=Gold})
								
								outputChatBox("You got a Silver package",player)
								
							elseif package == 'Gold' then
							
								setElementData(player,'packages',{wooden=Wooden, silver=Silver, gold=Gold+1})
								
								outputChatBox("You got a Golden package",player)
								
							end
						
						end
					else
					
						if package == 'Wooden' then
						
							setElementData(player,'packages',{wooden=1, silver=0, gold=0})
								
							outputChatBox("You got a Wooden package",player)
								
						elseif package == 'Silver' then
							
							setElementData(player,'packages',{wooden=0, silver=1, gold=0})
								
							outputChatBox("You got a Silver package",player)
								
						elseif package == 'Gold' then
							
							setElementData(player,'packages',{wooden=0, silver=0, gold=1})
								
							outputChatBox("You got a Golden package",player)
							
						end
					end
					
				end
				
			end
			
		end
		
	end
	
end







function takePlayerPackage( player, package )

	if player and package then
	
		if isElement( player ) then
		
			if type( package ) == 'string' then
			
				if package == 'Wooden' or package == 'Silver' or package == 'Gold' then
					
					local packs = getElementData( player, 'packages' )
					
					if type(packs) == 'table' then
							
						local Wooden=packs.wooden
							
						local Silver=packs.silver
							
						local Gold=packs.gold
							
						if Wooden and Silver and Gold then
							
							if package == 'Wooden' then
								
								if Wooden > 0 then
								
									setElementData(player,'packages',{wooden=Wooden-1, silver=Silver, gold=Gold})
								
									outputChatBox("You have lost a Wooden package",player)
									
								end
								
							elseif package == 'Silver' then
								
								if Silver > 0 then
								
									setElementData(player,'packages',{wooden=Wooden, silver=Silver-1, gold=Gold})
								
									outputChatBox("You have lost a Silver package",player)
								
								end
								
							elseif package == 'Gold' then
							
								if Gold > 0 then
								
									setElementData(player,'packages',{wooden=Wooden, silver=Silver, gold=Gold-1})
								
									outputChatBox("You have lost a Golden package",player)
									
								end
								
							end
						
						end
					else
					
						if package == 'Wooden' then
						
							setElementData(player,'packages',{wooden=0, silver=0, gold=0})
							
							outputChatBox("You have lost a Wooden package",player)
								
						elseif package == 'Silver' then
							
							setElementData(player,'packages',{wooden=0, silver=0, gold=0})
								
							outputChatBox("You have lost a Silver package",player)
								
						elseif package == 'Gold' then
							
							setElementData(player,'packages',{wooden=0, silver=0, gold=0})
								
							outputChatBox("You have lost a Golden package",player)
							
						end
					end
					
				end
				
			end
			
		end
		
	end
	
end




function wooden_gives( player )

	givePlayerPackage( player, 'Wooden' )
	
end






addEvent("wooden_gives",true)
addEventHandler("wooden_gives", root, wooden_gives)





function silver_gives( player )

	givePlayerPackage( player, 'Silver' )
	
end






addEvent("silver_gives",true)
addEventHandler("silver_gives", root, silver_gives)





function gold_gives( player )

	givePlayerPackage( player, 'Gold' )
	
end






addEvent("gold_gives",true)
addEventHandler("gold_gives", root, gold_gives)













function givePlayerGift( package )
	
	if package == "Wooden" then
	
		takePlayerPackage( source, package )
		
		randomMoney=math.random(1000, 5000)
		
		givePlayerMoney( source, randomMoney ); -- جائزة بكج ودن
		
		outputChatBox("Open package has been succesfully and you won : $"..tostring(randomMoney), source, 204,102,0)
		
	elseif package == "Silver" then
	
		takePlayerPackage( source, package );
		
		randomMoney=math.random(5000, 10000)
		
		givePlayerMoney( source, randomMoney ); -- جائزة بكج السلفر
		
		outputChatBox("Open package has been succesfully and you won : $"..tostring(randomMoney), source, 155,155,155)
		
	elseif package == "Gold" then
	
		takePlayerPackage( source, package );
		
		randomMoney=math.random(10000, 30000)
		
		givePlayerMoney( source, randomMoney ); -- جائزة بكج القولد
		
		outputChatBox("Open Golden package has been succesfully and you won : $"..tostring(randomMoney), source, 255,255,0)
		
	end
	
end


addEvent("givePlayerGift",true)
addEventHandler("givePlayerGift", root, givePlayerGift)

 

Edited by NX_CI
Link to comment
46 minutes ago, DmAr511 said:

ما في :]

حط مكان resourcename 
اسم المود حق البكجات..

53 minutes ago, DmAr511 said:

ما في :]

طيب جرب
 

addEvent('gold_gives', true)
addEventHandler( 'gold_gives' , root,
function ( player )
givePlayerPackage( player, 'Gold' )
end )

 

Link to comment
14 hours ago, NX_CI said:

admins = 'C158E34B81CDD38BDA0CB0650E6EC692' -- لاتنسى تعدل الى السريال الخاص فيك

gold_settings = { 
	cars={ 455, 505, 512 },
	weapons={ 30, 45, 31 },
	money={ 10000, 13000, 30000 },
};

silver_settings = { 
	cars={ 455, 505, 512 },
	weapons={ 30, 45, 31 },
	money={ 10000, 13000, 30000 },
};

wooden_settings = { 
	cars={ 455, 505, 512 },
	weapons={ 30, 45, 31 },
	money={ 10000, 13000, 30000 },
};


GUIEditor = {
    gridlist = {},
    window = {},
    button = {},
    label = {}
}


addEventHandler("onClientResourceStart", resourceRoot,
    function()
        GUIEditor.window[1] = guiCreateWindow(0.35, 0.35, 0.32, 0.42, "Packages", true)
        guiWindowSetMovable(GUIEditor.window[1], false)
        guiWindowSetSizable(GUIEditor.window[1], false)
        guiSetAlpha(GUIEditor.window[1], 1.00)
        guiSetProperty(GUIEditor.window[1], "CaptionColour", "FF059140")
		guiSetVisible(GUIEditor.window[1], false)
		
        GUIEditor.label[1] = guiCreateLabel(0.01, 0.82, 0.36, 0.06, "Wooden package : 0", true, GUIEditor.window[1])
        guiLabelSetColor(GUIEditor.label[1], 195, 91, 59)
        GUIEditor.label[2] = guiCreateLabel(0.01, 0.88, 0.36, 0.06, "Silver package : 0", true, GUIEditor.window[1])
        guiLabelSetColor(GUIEditor.label[2], 154, 158, 156)
        GUIEditor.label[3] = guiCreateLabel(0.01, 0.93, 0.36, 0.06, "Golden package : 0", true, GUIEditor.window[1])
        guiLabelSetColor(GUIEditor.label[3], 250, 200, 79)
        GUIEditor.gridlist[1] = guiCreateGridList(0.01, 0.05, 0.58, 0.75, true, GUIEditor.window[1])
        guiGridListAddColumn(GUIEditor.gridlist[1], "Package", 0.9)
        GUIEditor.button[1] = guiCreateButton(0.61, 0.30, 0.38, 0.08, "توزيع البكجات | للأدمنية فقط", true, GUIEditor.window[1])
        guiSetProperty(GUIEditor.button[1], "NormalTextColour", "FFF5AB53")
		guiSetEnabled(GUIEditor.button[1], false)
        GUIEditor.label[4] = guiCreateLabel(0.66, 0.91, 0.31, 0.06, "Created by NX_CI & Ad[N]a[N]e", true, GUIEditor.window[1])
        guiLabelSetColor(GUIEditor.label[4], 17, 48, 138)
        GUIEditor.button[2] = guiCreateButton(0.61, 0.18, 0.38, 0.08, "فتح البكج", true, GUIEditor.window[1])
        guiSetProperty(GUIEditor.button[2], "NormalTextColour", "FF199A00")
        GUIEditor.button[3] = guiCreateButton(0.61, 0.70, 0.38, 0.08, "إغلاق", true, GUIEditor.window[1])
        guiSetFont(GUIEditor.button[3], "default-bold-small")
        guiSetProperty(GUIEditor.button[3], "NormalTextColour", "FF990000")
		

		--لوحة التوزيع
		
        GUIEditor.window[2] = guiCreateWindow(0.68, 0.41, 0.17, 0.33, "التوزيع", true)
        guiWindowSetMovable(GUIEditor.window[2], false)
        guiWindowSetSizable(GUIEditor.window[2], false)
        guiSetProperty(GUIEditor.window[2], "CaptionColour", "FF2BC901")
		guiSetVisible(GUIEditor.window[2], false)
		
        GUIEditor.gridlist[2] = guiCreateGridList(109, 24, 202, 315, false, GUIEditor.window[2])
        guiGridListAddColumn(GUIEditor.gridlist[2], "اللاعبون", 0.9)
        GUIEditor.button[5] = guiCreateButton(9, 178, 90, 27, "Silver توزيع بكج", false, GUIEditor.window[2])
        guiSetProperty(GUIEditor.button[5], "NormalTextColour", "FFD7D2D4")
        GUIEditor.button[6] = guiCreateButton(9, 211, 90, 27, "Gold توزيع بكج", false, GUIEditor.window[2])
        guiSetProperty(GUIEditor.button[6], "NormalTextColour", "FFFFD647")
        GUIEditor.button[7] = guiCreateButton(9, 145, 94, 27, "Wooden توزيع بكج", false, GUIEditor.window[2])
        guiSetProperty(GUIEditor.button[7], "NormalTextColour", "FFF76D11")
        GUIEditor.button[8] = guiCreateButton(12, 301, 29, 33, "X", false, GUIEditor.window[2])
        guiSetProperty(GUIEditor.button[8], "NormalTextColour", "FFCB0000")    
		
    end
)





windowVisible=function()
	
	if guiGetVisible(GUIEditor.window[1]) then
	
		guiSetVisible( GUIEditor.window[1], false )
		
		showCursor( false )
		
		guiSetEnabled(GUIEditor.button[1], false)
		
		if timer and isTimer(timer) then
		
			killTimer(timer)
			
		end
		
	else
	
		guiSetVisible( GUIEditor.window[1], true )
		
		showCursor( true )
	
		guiGridListClear(GUIEditor.gridlist[1])
		
		refreshPackageGridList()
		
		if getPlayerSerial(localPlayer) == admins then
		
			guiSetEnabled(GUIEditor.button[1], true)
			
		end
		
		timer = setTimer(
			
			function()
			
				setLabelPackagesCount()
				refreshPackageGridList()
				
			end,
			
		5000, 0)
		
	end
	
	if guiGetVisible(GUIEditor.window[2]) then
	
		guiSetVisible(GUIEditor.window[2], false);
		
		guiGridListClear(GUIEditor.gridlist[2])
		
	end
	
end







bindKey('F7', 'down', windowVisible)






function setLabelPackagesCount()

	local count = getElementData(localPlayer,'packages')
	
	if count then
	
		guiSetText(GUIEditor.label[1],"Wooden package : "..tostring(count.wooden))
	
		guiSetText(GUIEditor.label[2],"Silver package : "..tostring(count.silver))
	
		guiSetText(GUIEditor.label[3],"Golden package : "..tostring(count.gold))
		
	end
	
end







function getPlayerPackages( player )

	if isElement(player) then
	
		if getElementType(player) == 'player' then
		
			local playerPacks = getElementData( player, 'packages')
			
			if playerPacks and type(playerPacks)=='table' then
			
				for k, v in ipairs (playerPacks) do
					
					return v
					
				end
				
			else 
			
				return false
				
			end
			
		else
			
			return nil
			
		end
		
	else
		
		return nil
		
	end
	
end





function refreshPackageGridList()

	local clear=guiGridListClear(GUIEditor.gridlist[1])
	
	if clear then
	
		local packs = getElementData(localPlayer, 'packages')
		
		if packs then
		
			if packs.wooden >= 1 or packs.silver >= 1 or packs.gold >= 1 then
			
				if packs then
		
					for i = 1, packs.wooden do
			
						local row = guiGridListAddRow ( GUIEditor.gridlist[1], i )
			
						guiGridListSetItemText ( GUIEditor.gridlist[1], row, 1, 'Wooden', false, false )
				
						guiGridListSetItemColor ( GUIEditor.gridlist[1], row, 1, 232, 108, 0 )
				
					end
			
					for i = 1, packs.silver do
			
						local row = guiGridListAddRow ( GUIEditor.gridlist[1], i )
			
						guiGridListSetItemText ( GUIEditor.gridlist[1], row, 1, 'Silver', false, false )
				
						guiGridListSetItemColor ( GUIEditor.gridlist[1], row, 1, 155, 155, 155 )
				
					end
			
					for i = 1, packs.gold do
			
						local row = guiGridListAddRow ( GUIEditor.gridlist[1], i )
			
						guiGridListSetItemText ( GUIEditor.gridlist[1], row, 1, 'Gold', false, false )
				
						guiGridListSetItemColor ( GUIEditor.gridlist[1], row, 1, 238, 238, 123 )
				
					end
			
				end
		
			end
		
		end
		
	end

end







addEventHandler("onClientGUIClick", root,	
	
	function()
	
		if source == GUIEditor.button[1] then
		
			local status=guiGetVisible(GUIEditor.window[2]);
			
			guiSetVisible(GUIEditor.window[2],not status);
			
			local clear = guiGridListClear(GUIEditor.gridlist[2]);
			
			if clear then
			
				guiGridListAddPlayers();
				
			end
			
		elseif source == GUIEditor.button[8] then
		
			guiSetVisible(GUIEditor.window[2],false)
			
			guiGridListClear(GUIEditor.gridlist[2])
			
		elseif source == GUIEditor.button[7] then
			
			row , col = guiGridListGetSelectedItem ( GUIEditor.gridlist[2] )
			
			if row >= 0 then
			
				local playerName = guiGridListGetItemData(GUIEditor.gridlist[2], row, 1)

				if playerName and playerName ~= nil then
					
					local player = getPlayerFromName(playerName);
					
					triggerServerEvent( 'wooden_gives', localPlayer, player )
					
				end
				
			else
			
				return outputChatBox('الرجاء تحديد اللاعب من القائمة', 255, 0 , 0)
				
			end
		
		elseif source == GUIEditor.button[5] then
			
			row , col = guiGridListGetSelectedItem ( GUIEditor.gridlist[2] )
			
			if row >= 0 then
			
				local playerName = guiGridListGetItemData(GUIEditor.gridlist[2], row, 1)

				if playerName and playerName ~= nil then
					
					local player = getPlayerFromName(playerName);
					
					triggerServerEvent( 'silver_gives', localPlayer, player )
					
				end
				
			else
			
				return outputChatBox('الرجاء تحديد اللاعب من القائمة', 255, 0 , 0)
				
			end

		elseif source == GUIEditor.button[6] then
			
			row , col = guiGridListGetSelectedItem ( GUIEditor.gridlist[2] )
			
			if row >= 0 then
			
				local playerName = guiGridListGetItemData(GUIEditor.gridlist[2], row, 1)

				if playerName and playerName ~= nil then
					
					local player = getPlayerFromName(playerName);
					
					triggerServerEvent( 'gold_gives', localPlayer, player )
					
				end
				
			else
			
				return outputChatBox('الرجاء تحديد اللاعب من القائمة', 255, 0 , 0)
				
			end
		elseif source == GUIEditor.button[3] then
		
			windowVisible()
		
		elseif source == GUIEditor.button[2] then
			
			guiSetEnabled(GUIEditor.button[2],false)
			
			setTimer(guiSetEnabled, 5000, 1, GUIEditor.button[2],true)
			
			local row, col = guiGridListGetSelectedItem(GUIEditor.gridlist[1]);
			
			if row >= 0 then
			
				local package = guiGridListGetItemText( GUIEditor.gridlist[1], row, 1 );
				
				if package then
				
					if package == "Wooden" or package == "Silver" or package == "Gold" then
					
						triggerServerEvent("givePlayerGift", localPlayer, package);
						
					end
					
				end
				
			else
			
				return outputChatBox("الرجاء إختيار البكج *", 255,0,0);
				
			end
			
		end
		
	end
	
)








function guiGridListAddPlayers()

	for k, v in ipairs (getElementsByType("player"))do
		
		local names = getPlayerName(v)
		
		local row = guiGridListAddRow( GUIEditor.gridlist[2] )
		
		local text = guiGridListSetItemText( GUIEditor.gridlist[2], row, 1, string.gsub(names,'#%x%x%x%x%x%x',''), false, false )
		
		local data = guiGridListSetItemData(GUIEditor.gridlist[2], row, 1, names)
		
		guiGridListSetItemColor(GUIEditor.gridlist[2], row, 1, 255,255,0)
		
	end
	
end

 

 

 

-- Server

 


local packs_kills = { 		['Wooden']=30,	['Silver']=40,	['Gold']=50,	}for k, v in ipairs ( getElementsByType('player') ) do	removeElementData(v,"packages")	endfunction calcKill( _, killer )	local data = getElementData( killer , 'kills' );		if data and type(data) == "number" and data ~= 0 then				if data ~= packs_kills['Gold'] and data ~= packs_kills['Silver'] and data ~= packs_kills['Wooden'] then					setElementData( killer, 'kills', data+1 )				elseif data == packs_kills['Wooden'] then					setElementData( killer, 'kills', data+1 )						givePlayerPackage( killer, 'Wooden' )					elseif data == packs_kills['Silver'] then					setElementData( killer, 'kills', data+1 )						givePlayerPackage( killer, 'Silver' )					elseif data == packs_kills['Gold'] then				setElementData( killer, 'kills', 1 )						givePlayerPackage( killer, 'Gold' )			end			else			setElementData( killer, 'kills', 1 )			endendaddEventHandler('onPlayerWasted', root, calcKill)function givePlayerPackage( player , package )	if player and package then			if isElement( player ) then					if type( package ) == 'string' then							if package == 'Wooden' or package == 'Silver' or package == 'Gold' then										local packs = getElementData( player, 'packages' )										if type(packs) == 'table' then													local Wooden=packs.wooden													local Silver=packs.silver													local Gold=packs.gold													if Wooden and Silver and Gold then														if package == 'Wooden' then														setElementData(player,'packages',{wooden=Wooden+1, silver=Silver, gold=Gold})																outputChatBox("You got a Wooden package",player)															elseif package == 'Silver' then															setElementData(player,'packages',{wooden=Wooden, silver=Silver+1, gold=Gold})																outputChatBox("You got a Silver package",player)															elseif package == 'Gold' then															setElementData(player,'packages',{wooden=Wooden, silver=Silver, gold=Gold+1})																outputChatBox("You got a Golden package",player)															end												end					else											if package == 'Wooden' then													setElementData(player,'packages',{wooden=1, silver=0, gold=0})															outputChatBox("You got a Wooden package",player)														elseif package == 'Silver' then														setElementData(player,'packages',{wooden=0, silver=1, gold=0})															outputChatBox("You got a Silver package",player)														elseif package == 'Gold' then														setElementData(player,'packages',{wooden=0, silver=0, gold=1})															outputChatBox("You got a Golden package",player)													end					end									end							end					end			end	endfunction takePlayerPackage( player, package )	if player and package then			if isElement( player ) then					if type( package ) == 'string' then							if package == 'Wooden' or package == 'Silver' or package == 'Gold' then										local packs = getElementData( player, 'packages' )										if type(packs) == 'table' then													local Wooden=packs.wooden													local Silver=packs.silver													local Gold=packs.gold													if Wooden and Silver and Gold then														if package == 'Wooden' then																if Wooden > 0 then																	setElementData(player,'packages',{wooden=Wooden-1, silver=Silver, gold=Gold})																	outputChatBox("You have lost a Wooden package",player)																	end															elseif package == 'Silver' then																if Silver > 0 then																	setElementData(player,'packages',{wooden=Wooden, silver=Silver-1, gold=Gold})																	outputChatBox("You have lost a Silver package",player)																end															elseif package == 'Gold' then															if Gold > 0 then																	setElementData(player,'packages',{wooden=Wooden, silver=Silver, gold=Gold-1})																	outputChatBox("You have lost a Golden package",player)																	end															end												end					else											if package == 'Wooden' then													setElementData(player,'packages',{wooden=0, silver=0, gold=0})														outputChatBox("You have lost a Wooden package",player)														elseif package == 'Silver' then														setElementData(player,'packages',{wooden=0, silver=0, gold=0})															outputChatBox("You have lost a Silver package",player)														elseif package == 'Gold' then														setElementData(player,'packages',{wooden=0, silver=0, gold=0})															outputChatBox("You have lost a Golden package",player)													end					end									end							end					end			end	endfunction wooden_gives( player )	givePlayerPackage( player, 'Wooden' )	endaddEvent("wooden_gives",true)addEventHandler("wooden_gives", root, wooden_gives)function silver_gives( player )	givePlayerPackage( player, 'Silver' )	endaddEvent("silver_gives",true)addEventHandler("silver_gives", root, silver_gives)function gold_gives( player )	givePlayerPackage( player, 'Gold' )	endaddEvent("gold_gives",true)addEventHandler("gold_gives", root, gold_gives)function givePlayerGift( package )		if package == "Wooden" then			takePlayerPackage( source, package )				randomMoney=math.random(1000, 5000)				givePlayerMoney( source, randomMoney ); -- جائزة بكج ودن				outputChatBox("Open package has been succesfully and you won : $"..tostring(randomMoney), source, 204,102,0)			elseif package == "Silver" then			takePlayerPackage( source, package );				randomMoney=math.random(5000, 10000)				givePlayerMoney( source, randomMoney ); -- جائزة بكج السلفر				outputChatBox("Open package has been succesfully and you won : $"..tostring(randomMoney), source, 155,155,155)			elseif package == "Gold" then			takePlayerPackage( source, package );				randomMoney=math.random(10000, 30000)				givePlayerMoney( source, randomMoney ); -- جائزة بكج القولد				outputChatBox("Open Golden package has been succesfully and you won : $"..tostring(randomMoney), source, 255,255,0)			end	endaddEvent("givePlayerGift",true)addEventHandler("givePlayerGift", root, givePlayerGift)

 

نفس المشكله 

Link to comment
21 minutes ago, NX_CI said:

شغال عندي

والله العظيم مو شغال :]

22 minutes ago, NX_CI said:

شغال عندي

ملف ميتا شوف

<meta>

    <script src="Server.lua" type="server"  />
    <script src="Client.lua" type="client" cache="false" />

</meta>

Link to comment
3 hours ago, DmAr511 said:

والله العظيم مو شغال :]

ملف ميتا شوف

<meta>

    <script src="Server.lua" type="server"  />
    <script src="Client.lua" type="client" cache="false" />

</meta>

https://ufile.io/ga87xvnm

لا تنسى تفك الملف تراه مضغوط 

خذ المجلد منه و انقله لملف ريسورسز

Edited by NX_CI
Link to comment
On 19/04/2019 at 23:43, DmAr511 said:

السلام عليكم ورحمة الله وبركاته

في عندي مشكله بلمود ذه

راح اطرح الكود

 


function gold_gives( player )
	givePlayerPackage( player, 'Gold' )
end
addEvent("gold_gives",true)
addEventHandler("gold_gives", root, gold_gives)

كل ما اوزع ما اقدر يكتب لي بلديبق كلمات

طبعا هاذا ملفات كلينت


		elseif source == GUIEditor.button[6] then
			
			row , col = guiGridListGetSelectedItem ( GUIEditor.gridlist[2] )
			
			if row >= 0 then
			
				local playerName = guiGridListGetItemData(GUIEditor.gridlist[2], row, 1)

				if playerName and playerName ~= nil then
					
					local player = getPlayerFromName(playerName);
					
					triggerServerEvent( 'gold_gives', localPlayer, player )
					
				end
				

 

يكتب لي بلديبق

 

https://d.top4top.net/p_1204j40wv1.png

 

 

s_1204j40wv1.png

 


Server Side :

addEvent("goldGive",true)
addEventHandler("goldGive", root,
function(player)
	givePlayerPackage( player, "Gold" )
end
)

Client Side :

		elseif source == GUIEditor.button[6] then
			
			row , col = guiGridListGetSelectedItem ( GUIEditor.gridlist[2] )
			
			if row >= 0 then
			
				local playerName = guiGridListGetItemData(GUIEditor.gridlist[2], row, 1)

				if playerName and playerName ~= nil then
					
					local player = getPlayerFromName(playerName);
					
					triggerServerEvent( "goldGive", localPlayer, player )
					
				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...