Jump to content

مساعدة


Guest

Recommended Posts

بدي عدد اللاعبين على قيد حياة يكتب رقمهم

addEvent ("AlivePlayersTrigger",true)
addEventHandler ("AlivePlayersTrigger",root,
function ()
local alivePlayers = getAlivePlayers ()
end
)
    		triggerServerEvent ( "AlivePlayersTrigger", localPlayer)
	dxDrawText("#ffffffAlive players:"..alivePlayers.." ", (483/1024)*sWidth, (15/768)*sHeight, (289/1024)*sWidth, (250/768)*sHeight, tocolor (0, 0, 0, 255), (1/1366)*sWidth,(1/768)*sHeight,"default-bold","left","top",false,false,false,true)

 

Link to comment

Client

addEventHandler('onClientRender',root,
	function()
		dxDrawText('Players Count :'..tonumber(getElementData(resourceRoot,'Players')) or 0, 63, 231, 466, 305, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, false, false, false)
	end
)

Server : 

function Count()
	setElementData(resourceRoot,'Players',#getAlivePlayers())
end
setTimer(Count,50,0)

 

OR

Server

setTimer(function()
	triggerClientEvent('GetNumber',root,#getAlivePlayers())
end,50,0)

Client

addEvent('GetNumber',true)
addEventHandler('GetNumber',root,
	function(Number2)
		Number = Number2
	end
)

	addEventHandler('onClientRender',root,
		function()
			dxDrawText('Players Count :'..Number or 0, 63, 231, 466, 305, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, false, false, false)
		end
)

 

Edited by KillerX
  • Like 1
  • Thanks 1
Link to comment
4 hours ago, KillerX said:

Client


addEventHandler('onClientRender',root,
	function()
		dxDrawText('Players Count :'..tonumber(getElementData(resourceRoot,'Players')) or 0, 63, 231, 466, 305, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, false, false, false)
	end
)

Server : 


function Count()
	setElementData(resourceRoot,'Players',#getAlivePlayers())
end
setTimer(Count,50,0)

 

OR

Server


setTimer(function()
	triggerClientEvent('GetNumber',root,#getAlivePlayers())
end,50,0)

Client


addEvent('GetNumber',true)
addEventHandler('GetNumber',root,
	function(Number2)
		Number = Number2
	end
)

	addEventHandler('onClientRender',root,
		function()
			dxDrawText('Players Count :'..Number or 0, 63, 231, 466, 305, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, false, false, false)
		end
)

 

طرقك تجيب اللاق استعمل هذي الطريقة افضل : - 
 

table.filter = function(t, filterIter)
    local out = {}

    for k, v in pairs(t) do
      if filterIter(v, k, t) then out[k] = v end
    end

    return out
end
addEventHandler('onClientRender',root,
		function()
			local filter = table.filter(getElementsByType('player'), function ( player, k, v ) return not isPedDead( player ) end )
			dxDrawText('Players Count :'.. #filter or 0, 63, 231, 466, 305, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, false, false, false)
		end
)

غير مجرب : )

Edited by iMr.WiFi..!
توضيح للكود اكثر
Link to comment
25 minutes ago, iMr.WiFi..! said:

طرقك تجيب اللاق استعمل هذي الطريقة افضل : - 
 


table.filter = function(t, filterIter)
    local out = {}

    for k, v in pairs(t) do
      if filterIter(v, k, t) then out[k] = v end
    end

    return out
end
addEventHandler('onClientRender',root,
		function()
			local filter = table.filter(getElementsByType('player'), function ( player, k, v ) return not isPedDead( player ) end )
			dxDrawText('Players Count :'.. #filter or 0, 63, 231, 466, 305, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, false, false, false)
		end
)

غير مجرب : )

بس مو طريقتك لوب لكل اللاعبين داخل رندر ؟ ما تجيب لاق ذي كمان ؟

Link to comment
2 minutes ago, #َxLysandeR said:

بس مو طريقتك لوب لكل اللاعبين داخل رندر ؟ ما تجيب لاق ذي كمان ؟

كل واحد وطريقته انا اشوف ان لو حصر اللاق من جهة واحده افضل من جهتين - اقصد بهم الكلاينت والسيرفر - 

 

Link to comment
12 minutes ago, iMr.WiFi..! said:

كل واحد وطريقته انا اشوف ان لو حصر اللاق من جهة واحده افضل من جهتين - اقصد بهم الكلاينت والسيرفر - 

 

+ 1 

او ممكن يسوي طريقه اخره جت علي بالي

local AlivePlayers, Events = 0, {"Wasted", "Spawn", "Quit", "Join"}

function updateAlivePlayers()
  AlivePlayers = 0
  for i,v in ipairs(getElementsByType("player")) do
    if not isPedDead(v) then
      AlivePlayers = AlivePlayers + 1
    end
  end
end
for _,event in ipairs(Events) do
  addEventHandler("onClientPlayer"..event, root, updateAlivePlayers)
end

بحيث نتجنب اللوب في الريندر

  • Like 2
Link to comment
7 hours ago, #َxLysandeR said:

+ 1 

او ممكن يسوي طريقه اخره جت علي بالي


local AlivePlayers, Events = 0, {"Wasted", "Spawn", "Quit", "Join"}

function updateAlivePlayers()
  AlivePlayers = 0
  for i,v in ipairs(getElementsByType("player")) do
    if not isPedDead(v) then
      AlivePlayers = AlivePlayers + 1
    end
  end
end
for _,event in ipairs(Events) do
  addEventHandler("onClientPlayer"..event, root, updateAlivePlayers)
end

بحيث نتجنب اللوب في الريندر

آسف على الفضول

شكلي محشش ولا

ممكن تقولي وش الإيفنت الجديد ذا

  addEventHandler("onClientPlayer"..event, root, updateAlivePlayers)
Link to comment
4 minutes ago, coNolel said:

آسف على الفضول

شكلي محشش ولا

ممكن تقولي وش الإيفنت الجديد ذا


  addEventHandler("onClientPlayer"..event, root, updateAlivePlayers)

يسوي لوب علي الجدول اللي في Wasted , Spawn

عشان تصير بالشكل دا يعني

onClientPlayer..event = onClientPlayerWasted و باقي الجدول

  • Like 2
Link to comment
11 hours ago, #َxLysandeR said:

 


local AlivePlayers, Events = 0, {"Wasted", "Spawn", "Quit", "Join"}

function updateAlivePlayers()
  AlivePlayers = 0
  for i,v in ipairs(getElementsByType("player")) do
    if not isPedDead(v) then
      AlivePlayers = AlivePlayers + 1
    end
  end
end
for _,event in ipairs(Events) do
  addEventHandler("onClientPlayer"..event, root, updateAlivePlayers)
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...