Jump to content

x[ استفسار ]x getPlayerID ايدي اللاعب


Avir14

Recommended Posts

-- ابيه يجيب ايدي اللاعب
-- Client
function mid ( commandName )
local idd = exports.ids:getPlayerID(player)
outputChatBox("Your ID IS"..idd, source, 0, 154, 255)
end    
addCommandHandler ( "myid", escapeMe )

-- مود الايدي الي اسوي منه export

local optimize = true -- Should the script be optimized? (if optimized, cannot be used client-side)
local ids = {}

function assignID()
	for i=1,getMaxPlayers() do
		if not ids[i] then
			ids[i] = source
			setElementData(source,"id",i,not optimize)
			break
		end
	end
end
addEventHandler("onPlayerJoin",root,assignID)

function startup()
	for k, v in ipairs(getElementsByType("player")) do
		local id = getElementData(v,"id")
		if id then ids[id] = v end
	end
end
addEventHandler("onResourceStart",resourceRoot,startup)

function getPlayerID(player)
	for k, v in ipairs(ids) do
		if v == player then return k end
	end
end

function freeID()
	local id = getElementData(source,"id")
	if not id then return end
	ids[id] = nil
end
addEventHandler("onPlayerQuit",root,freeID)

function getPlayerByID(id)
	local player = ids[id]
	return player or false
end


-- debugscript الدي بق

ERROR: script\c.lua:2: call: failed to call 'ids:getPlayerID' [string "?"]
ERROR: script\c.lua:3: attempt to concatenate local 'idd (a boolean value)

حل جزاكم الله خيرا

Link to comment
-- مود الايدي الي اسوي منه export

local optimize = true -- Should the script be optimized? (if optimized, cannot be used client-side)
local ids = {}

function assignID()
	for i=1,getMaxPlayers() do
		if not ids[i] then
			ids[i] = source
			setElementData(source,"id",i,not optimize)
			break
		end
	end
end
addEventHandler("onPlayerJoin",root,assignID)

function startup()
	for k, v in ipairs(getElementsByType("player")) do
		local id = getElementData(v,"id")
		if id then ids[id] = v end
	end
end
addEventHandler("onResourceStart",resourceRoot,startup)

function getPlayerID(player)
	for k, v in ipairs(ids) do
		if v == player then return k end
	end
end

function freeID()
	local id = getElementData(source,"id")
	if not id then return end
	ids[id] = nil
end
addEventHandler("onPlayerQuit",root,freeID)

function getPlayerByID(id)
	local player = ids[id]
	return player or false
end

-- ابيه يجيب ايدي اللاعب
-- Client
function mid ( player, commandName )
outputChatBox("Your ID IS"..getPlayerID(player), player, 0, 154, 255)
end    
addCommandHandler ( "myid", mid )

 

Edited by #\_oskar_/#
Link to comment
12 hours ago, #\_oskar_/# said:
-- مود الايدي الي اسوي منه export

local optimize = true -- Should the script be optimized? (if optimized, cannot be used client-side)
local ids = {}

function assignID()
	for i=1,getMaxPlayers() do
		if not ids[i] then
			ids[i] = source
			setElementData(source,"id",i,not optimize)
			break
		end
	end
end
addEventHandler("onPlayerJoin",root,assignID)

function startup()
	for k, v in ipairs(getElementsByType("player")) do
		local id = getElementData(v,"id")
		if id then ids[id] = v end
	end
end
addEventHandler("onResourceStart",resourceRoot,startup)

function getPlayerID(player)
	for k, v in ipairs(ids) do
		if v == player then return k end
	end
end

function freeID()
	local id = getElementData(source,"id")
	if not id then return end
	ids[id] = nil
end
addEventHandler("onPlayerQuit",root,freeID)

function getPlayerByID(id)
	local player = ids[id]
	return player or false
end

-- ابيه يجيب ايدي اللاعب
-- Client
function mid ( player, commandName )
outputChatBox("Your ID IS"..getPlayerID(player), player, 0, 154, 255)
end    
addCommandHandler ( "myid", mid )

 

ما اشتغل للاسف كذا كاتبلي بالدي بق

ERROR: script\ c.lua:44: attempt to concatenate a nil value

outputChatBox("Your ID IS"..getPlayerID(player), player, 0, 154, 255)

 

Link to comment
14 hours ago, Avir14 said:

ما اشتغل للاسف كذا كاتبلي بالدي بق

ERROR: script\ c.lua:44: attempt to concatenate a nil value

outputChatBox("Your ID IS"..getPlayerID(player), player, 0, 154, 255)

 

 

 

local optimize = true -- Should the script be optimized? (if optimized, cannot be used client-side)
local ids = {}

function assignID()
	for i=1,getMaxPlayers() do
		if not ids[i] then
			ids[i] = source
			setElementData(source,"id",i,not optimize)
			break
		end
	end
end
addEventHandler("onPlayerJoin",root,assignID)

function startup()
	for k, v in ipairs(getElementsByType("player")) do
		local id = getElementData(v,"id")
		if id then ids[id] = v end
	end
end
addEventHandler("onResourceStart",resourceRoot,startup)

function getPlayerID(player)
	for k, v in ipairs(ids) do
		if v == player then return k end
	end
end

function freeID()
	local id = getElementData(source,"id")
	if not id then return end
	ids[id] = nil
end
addEventHandler("onPlayerQuit",root,freeID)

function getPlayerByID(id)
	local player = ids[id]
	return player or false
end

-- ابيه يجيب ايدي اللاعب
-- Client
function mid ( player, commandName )
outputChatBox("Your ID IS"..getPlayerID(player), player, 0, 154, 255, true)
end    
addCommandHandler ( "myid", mid )

 

Link to comment
5 hours ago, +Source|> said:

 

 

local optimize = true -- Should the script be optimized? (if optimized, cannot be used client-side)
local ids = {}

function assignID()
	for i=1,getMaxPlayers() do
		if not ids[i] then
			ids[i] = source
			setElementData(source,"id",i,not optimize)
			break
		end
	end
end
addEventHandler("onPlayerJoin",root,assignID)

function startup()
	for k, v in ipairs(getElementsByType("player")) do
		local id = getElementData(v,"id")
		if id then ids[id] = v end
	end
end
addEventHandler("onResourceStart",resourceRoot,startup)

function getPlayerID(player)
	for k, v in ipairs(ids) do
		if v == player then return k end
	end
end

function freeID()
	local id = getElementData(source,"id")
	if not id then return end
	ids[id] = nil
end
addEventHandler("onPlayerQuit",root,freeID)

function getPlayerByID(id)
	local player = ids[id]
	return player or false
end

-- ابيه يجيب ايدي اللاعب
-- Client
function mid ( player, commandName )
outputChatBox("Your ID IS"..getPlayerID(player), player, 0, 154, 255, true)
end    
addCommandHandler ( "myid", mid )

 

للاسف ماشتغل لسا نفس المشكلة

ERROR: script\ c.lua:44: attempt to concatenate a nil value

Link to comment
3 hours ago, Avir14 said:

للاسف ماشتغل لسا نفس المشكلة

ERROR: script\ c.lua:44: attempt to concatenate a nil value

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

onPlayerJoin

شغل المود وسوي ريكونكت......

Link to comment
9 hours ago, +Source|> said:

 

 

local optimize = true -- Should the script be optimized? (if optimized, cannot be used client-side)
local ids = {}

function assignID()
	for i=1,getMaxPlayers() do
		if not ids[i] then
			ids[i] = source
			setElementData(source,"id",i,not optimize)
			break
		end
	end
end
addEventHandler("onPlayerJoin",root,assignID)

function startup()
	for k, v in ipairs(getElementsByType("player")) do
		local id = getElementData(v,"id")
		if id then ids[id] = v end
	end
end
addEventHandler("onResourceStart",resourceRoot,startup)

function getPlayerID(player)
	for k, v in ipairs(ids) do
		if v == player then return k end
	end
end

function freeID()
	local id = getElementData(source,"id")
	if not id then return end
	ids[id] = nil
end
addEventHandler("onPlayerQuit",root,freeID)

function getPlayerByID(id)
	local player = ids[id]
	return player or false
end

-- ابيه يجيب ايدي اللاعب
-- Client
function mid ( player, commandName )
outputChatBox("Your ID IS"..getPlayerID(player), player, 0, 154, 255, true)
end    
addCommandHandler ( "myid", mid )

 

يعطيك العافية 

المشكلة كان لها سببين 

السبب الاول اني كنت حاط الاكواد بملف كلاينت والمفترض احطها بملف سيرفر

والسبب الثاني اني ماكنت اسوي اشغل المود بعدين اطلع واخش من السيرفر

  • Like 1
Link to comment
25 minutes ago, Avir14 said:

يعطيك العافية 

المشكلة كان لها سببين 

السبب الاول اني كنت حاط الاكواد بملف كلاينت والمفترض احطها بملف سيرفر

والسبب الثاني اني ماكنت اسوي اشغل المود بعدين اطلع واخش من السيرفر

بالتوفيق ::)

Edited by +Source|>
  • Like 1
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...