Jump to content

تحقق رتب


Recommended Posts

سلام عليكم

 كنت ابي اسوي اذا انا معي رتبة كونسل 2 يكون معي كل صلاحيات الرتب الي تحتي في الجدول لكن كونسل 1 الي اعلي مني في الجدول ما تكون معي

ولو انا اعلي رتبة في الجدول مثلا , كل الرتب الي تحتي لي صلاحياتها

ومثلا لو انا اخر واحد بالجدول تحت , ما يكون معي صلاحيات من الجدول نهائي الا اخر رتبة

local ranks = { 
[1] = {"Console"},
[2] = {"Console2"},
[3] = {"Admins"},
[4] = {"Admins1"},
}

vi = 0

function isRank(player,rank)
	  local playerAccount = getPlayerAccount ( player ) 
	if player and rank then
		for i, v in ipairs ( ranks ) do
			if v[1] == rank then
				vi = i
				outputChatBox(i,root)
				return
			end
		end
		for ii, vv in ipairs ( ranks ) do
			if ii < vi+1 then
				if ( isObjectInACLGroup ( "user."..getAccountName(playerAccount),aclGetGroup(vv[1]) ) ) then 
					outputChatBox(vv[1],root,255,0,0,true)
					rk = "true"
				end
				
			end
		end
	end
	if rk == "true" then
		return true
	else 
		return false
	end
end

addCommandHandler("checkRank",
	function(source)
		local ra = isRank(source,"Console2")
			if ra == true then
				outputChatBox("true")
			else
				outputChatBox("false")
			end
	end
)

**اسف علي التخبيص هادا :(**

Link to comment

ماني متأكد اني فهمتك بس اعتقد المفروض تعدل بالاسل نفسه ، تسوي  اسل قروب للرتب وبعدها تضيفها وحدة وحدة

ولا قصدك انه مثلا لو معك كونسل تبي يدخلك برضو قروب كونسل 2 ادمن وادمن 1؟

Link to comment
2 hours ago, HassoN said:

ماني متأكد اني فهمتك بس اعتقد المفروض تعدل بالاسل نفسه ، تسوي  اسل قروب للرتب وبعدها تضيفها وحدة وحدة

ولا قصدك انه مثلا لو معك كونسل تبي يدخلك برضو قروب كونسل 2 ادمن وادمن 1؟

يعني مثلا الحين انا كونسل 2 المفروض ان رتبتي اقل من كونسل 1

وكونسل 1 اعلي مني 

وادمن اقل مني 

لو جا الادمن يكتب الكوماند ما تظبط معه

لان صلاحيات الكوماند كونسل 2 فوق

لو جا كونسل 2 يكتب الكوماند يظبط 

لو جا كونسل 1 يكتب يظبط لانه اعلي من كونسل 2

Link to comment

بذي الحالة عندك حلين: 

1. تستعمل 

hasObjectPermissionTo

عشان تتحقق من خاصية معينة تكون عند كل الادمنية الي يقدرون يستعملون الكوماند حقك ، او العكس مثلا كونسل 1 عنده خاصية ماعندها الكونسل 2 ف تتحقق من وجودها او عدمه

2. بكل بساطة تسوي فنكشن يجيب رتبة اللاعب ويعطيه تلقائي كل الرتب الي اوطى منه

Link to comment
3 hours ago, HassoN said:

بذي الحالة عندك حلين: 

1. تستعمل 


hasObjectPermissionTo

عشان تتحقق من خاصية معينة تكون عند كل الادمنية الي يقدرون يستعملون الكوماند حقك ، او العكس مثلا كونسل 1 عنده خاصية ماعندها الكونسل 2 ف تتحقق من وجودها او عدمه

2. بكل بساطة تسوي فنكشن يجيب رتبة اللاعب ويعطيه تلقائي كل الرتب الي اوطى منه

انا ابي نفس فكرة الكود حقي , بس تصحيح له بس

Link to comment

جرب

 

local ranks = { 
[1] = {"Console"},
[2] = {"Console2"},
[3] = {"Admins"},
[4] = {"Admins1"},
}

vi = 0

function isRank(player,rank)
	local playerAccount = getPlayerAccount ( player ) 
	if player and rank then
		for i, v in ipairs ( ranks ) do
			if v == rank then
				vi = i
				outputChatBox(tostring(i),root)
				return
			end
		end
		for ii, vv in ipairs ( ranks ) do
			if ii < vi+1 then
				if ( isObjectInACLGroup ( "user."..getAccountName(playerAccount),aclGetGroup(vv) ) ) then 
					outputChatBox(vv,root,255,0,0,true)
					rk = "true"
				end
				
			end
		end
	end
	if rk == "true" then
		return true
	else 
		return false
	end
end

addCommandHandler("checkRank",
	function(source)
		local ra = isRank(source,"Console2")
			if ra == true then
				outputChatBox("true")
			else
				outputChatBox("false")
			end
	end
)

 

Link to comment

للبوست حقي فوقEdit ما ادري ليش ما اقدر اسوي 
بس المهم توني انتبه على كم غلط ثانين ف عدلتهم

 

local ranks = { 
[1] = "Console",
[2] = "Console2",
[3] = "Admins",
[4] = "Admins1",
}


vi = 0

function isRank(player,rank)
	local playerAccount = getPlayerAccount ( player ) 
	if player and rank then
		for i, v in ipairs ( ranks ) do
			if v == rank then
				vi = i
				outputChatBox(tostring(i),root)
			end
		end
		for ii, vv in ipairs ( ranks ) do
			if ii < vi+1 then
				if ( isObjectInACLGroup ( "user."..getAccountName(playerAccount),aclGetGroup(vv) ) ) then 
					outputChatBox(vv,root,255,0,0,true)
					rk = "true"
				end
				
			end
		end
	end
	if rk == "true" then
		return true
	else 
		return false
	end
end


addCommandHandler("checkRank",
	function(source)
		local ra = isRank(source,"Console")
			if ra == true then
				outputChatBox("true")
			else
				outputChatBox("false")
			end
	end
)


المفروض كذا يطلع لك فالشات كذا
1

Console
true

 

مع العلم اني للحين مو فاهم ايش تبي فيهم كذا 

Edited by HassoN
Link to comment
4 hours ago, HassoN said:

مع العلم اني للحين مو فاهم ايش تبي فيهم كذا 

مثلا في رتب

1

2

3

طبعا 3 اعلي رتبة

الحين ابي اسوي نظام رتب علي اساس لو الشخص معه رتبة رقم 3 , يكون معه صلاحيات رتبة 2 و 1

يعني لما يتحقق من الرتبة ورتبته اعلي واحدة في الجدول يكون كل الرتب الي تحت عادي

يعني مثلا لو انا رتبة 3 والتحقق علي الرتبة رقم 2

يظبط عادي , لاني معي 3 مع ان التحقق 2 لكن انا اعلي شي في الجدول

 

Link to comment
local ranksNumbers = {
["Console"] = 1,
["Console2"] = 2,
["Admins"] = 3,
["Admins1"] = 4,
}


function isRank(player,rank)
	local playerAccount = getPlayerAccount ( player ) 
	local groups = aclGetAccountGroups( playerAccount)
	for i, v in ipairs(groups) do
		if ranksNumbers[v] then
			if (ranksNumbers[v] <= ranksNumbers[rank]) then
				status = true
				return status
			end
		end
	end
	if (not status) then
		return false
	end
end

function checkGroup(plr)
	local result = isRank(plr,"Console")
	outputChatBox(tostring(result))
end
addCommandHandler("checkRank", checkGroup)

function aclGetAccountGroups ( account ) 
    local acc = getAccountName ( account ) 
    if ( not acc ) then return false end 
    local res = {} 
    acc = "user."..acc 
    local all = "user.*" 
    for ig, group in ipairs ( aclGroupList() ) do 
        for io, object in ipairs ( aclGroupListObjects ( group ) ) do 
            if ( ( acc == object ) or ( all == object ) ) then 
                table.insert ( res, aclGroupGetName ( group ) ) 
                break 
            end 
        end 
    end 
    return res 
end

 

لو انت كونسل وكتبت
isRank(plr, "Console")
بيرجع لك true

ولو كتبت

isRank(plr, "Console2")
المفروض يرجع لك برضو true

nil لكن لو العكس (انت كونسل 2 وكتبت كونسل العادي الي هو المفروض اعلى منك) راح يرجع لك 

Edited by HassoN
Link to comment
7 minutes ago, HassoN said:

لو انت كونسل وكتبت
isRank(plr, "Console")
بيرجع لك true

ولو كتبت

isRank(plr, "Console2")
المفروض يرجع لك برضو true

nil لكن لو العكس (انت كونسل 2 وكتبت كونسل العادي الي هو المفروض اعلى منك) راح يرجع لك 

يب هادا الي ابيه بالظبط

شكرا لك ❤️

Link to comment
  • 2 weeks later...
On 07/07/2019 at 02:54, HassoN said:

local ranksNumbers = {
["Console"] = 1,
["Console2"] = 2,
["Admins"] = 3,
["Admins1"] = 4,
}


function isRank(player,rank)
	local playerAccount = getPlayerAccount ( player ) 
	local groups = aclGetAccountGroups( playerAccount)
	for i, v in ipairs(groups) do
		if ranksNumbers[v] then
			if (ranksNumbers[v] <= ranksNumbers[rank]) then
				status = true
				return status
			end
		end
	end
	if (not status) then
		return false
	end
end

function checkGroup(plr)
	local result = isRank(plr,"Console")
	outputChatBox(tostring(result))
end
addCommandHandler("checkRank", checkGroup)

function aclGetAccountGroups ( account ) 
    local acc = getAccountName ( account ) 
    if ( not acc ) then return false end 
    local res = {} 
    acc = "user."..acc 
    local all = "user.*" 
    for ig, group in ipairs ( aclGroupList() ) do 
        for io, object in ipairs ( aclGroupListObjects ( group ) ) do 
            if ( ( acc == object ) or ( all == object ) ) then 
                table.insert ( res, aclGroupGetName ( group ) ) 
                break 
            end 
        end 
    end 
    return res 
end

 

لو انت كونسل وكتبت
isRank(plr, "Console")
بيرجع لك true

ولو كتبت

isRank(plr, "Console2")
المفروض يرجع لك برضو true

nil لكن لو العكس (انت كونسل 2 وكتبت كونسل العادي الي هو المفروض اعلى منك) راح يرجع لك 

local ranksNumbers = { 
{1,"Console","ConsoleData"},
{2,"Console2","Console2D"},
{3,"Admins","Admins29"},
}



function isRank(player,rank)
	local playerAccount = getPlayerAccount ( player ) 
	local groups = aclGetAccountGroups( playerAccount)
	 if not isGuestAccount ( playerAccount ) then
	for i, v in ipairs(groups) do
		if ranksNumbers[v] then
			if (ranksNumbers[v][1] <= ranksNumbers[rank]) then
				status = true
				return status
			end
		end
	end
	if (not status) then
		return false
	end
	end
end


addCommandHandler("checkRank",
	function(source)
	local result = isRank(source,"Console2")
	outputChatBox(tostring(result))
	end
)



function aclGetAccountGroups ( account ) 
    local acc = getAccountName ( account ) 
    if ( not acc ) then return false end 
    local res = {} 
    acc = "user."..acc 
    local all = "user.*" 
    for ig, group in ipairs ( aclGroupList() ) do 
        for io, object in ipairs ( aclGroupListObjects ( group ) ) do 
            if ( ( acc == object ) or ( all == object ) ) then 
                table.insert ( res, aclGroupGetName ( group ) ) 
                break 
            end 
        end 
    end 
    return res 
end

حاولت اظبطها علي نظام الجدول هادا بس ما عرفت :( 

يعني بدل

["Console"] = 1

تكون

{

""1"","Console

}

وهكذا

Link to comment

مو مجرب 

 


local ranksNumbers = { 
{1,"Console","ConsoleData"},
{2,"Console2","Console2D"},
{3,"Admins","Admins29"},
}



function isRank(player,rank)
	local playerAccount = getPlayerAccount ( player ) 
	local groups = aclGetAccountGroups( playerAccount)
	 if not isGuestAccount ( playerAccount ) then
	for i, v in ipairs(groups) do
		local index = getIndexFromValue(v)
		if index then
			local otherIndex = getIndexFromValue(rank)
			if (index <= otherIndex) then
				status = true
				return status
			end
		end
	end
	if (not status) then
		return false
	end
	end
end


addCommandHandler("checkRank",
	function(source)
	local result = isRank(source,"Console2")
	outputChatBox(tostring(result))
	end
)

function getIndexFromValue(value)
	for i, v in ipairs(ranksNumbers) do
		if v[2] == value then
			return v[1]
		end
	end
end


function aclGetAccountGroups ( account ) 
    local acc = getAccountName ( account ) 
    if ( not acc ) then return false end 
    local res = {} 
    acc = "user."..acc 
    local all = "user.*" 
    for ig, group in ipairs ( aclGroupList() ) do 
        for io, object in ipairs ( aclGroupListObjects ( group ) ) do 
            if ( ( acc == object ) or ( all == object ) ) then 
                table.insert ( res, aclGroupGetName ( group ) ) 
                break 
            end 
        end 
    end 
    return res 
end

 

Link to comment
1 hour ago, HassoN said:

مو مجرب 

 


local ranksNumbers = { 
{1,"Console","ConsoleData"},
{2,"Console2","Console2D"},
{3,"Admins","Admins29"},
}



function isRank(player,rank)
	local playerAccount = getPlayerAccount ( player ) 
	local groups = aclGetAccountGroups( playerAccount)
	 if not isGuestAccount ( playerAccount ) then
	for i, v in ipairs(groups) do
		local index = getIndexFromValue(v)
		if index then
			local otherIndex = getIndexFromValue(rank)
			if (index <= otherIndex) then
				status = true
				return status
			end
		end
	end
	if (not status) then
		return false
	end
	end
end


addCommandHandler("checkRank",
	function(source)
	local result = isRank(source,"Console2")
	outputChatBox(tostring(result))
	end
)

function getIndexFromValue(value)
	for i, v in ipairs(ranksNumbers) do
		if v[2] == value then
			return v[1]
		end
	end
end


function aclGetAccountGroups ( account ) 
    local acc = getAccountName ( account ) 
    if ( not acc ) then return false end 
    local res = {} 
    acc = "user."..acc 
    local all = "user.*" 
    for ig, group in ipairs ( aclGroupList() ) do 
        for io, object in ipairs ( aclGroupListObjects ( group ) ) do 
            if ( ( acc == object ) or ( all == object ) ) then 
                table.insert ( res, aclGroupGetName ( group ) ) 
                break 
            end 
        end 
    end 
    return res 
end

 

يب ظبطت تسلم , بس عندي استفسار

الكود هادا صحيح , المفروض اني مسويه يجيب اعلي رتبة مع الاعب في الجدول

function getPlayerRank(player)
	local playerAccount = getPlayerAccount ( player ) 
	local groups = ranksNumbers
	if not isGuestAccount ( playerAccount ) then
		for i, v in ipairs(groups) do
			if isObjectInACLGroup ( "user."..getAccountName ( playerAccount ), aclGetGroup ( v[2] ) ) then
				outputChatBox(v[2],root,255,0,0,true)
				status = v[2]
				  return status
			end
		end
		if (not status) then
			return "Player"
		end
	end
end

 

Link to comment
3 minutes ago, Mr.Mostafa said:

يب ظبطت تسلم , بس عندي استفسار

الكود هادا صحيح , المفروض اني مسويه يجيب اعلي رتبة مع الاعب في الجدول


function getPlayerRank(player)
	local playerAccount = getPlayerAccount ( player ) 
	local groups = ranksNumbers
	if not isGuestAccount ( playerAccount ) then
		for i, v in ipairs(groups) do
			if isObjectInACLGroup ( "user."..getAccountName ( playerAccount ), aclGetGroup ( v[2] ) ) then
				outputChatBox(v[2],root,255,0,0,true)
				status = v[2]
				  return status
			end
		end
		if (not status) then
			return "Player"
		end
	end
end

 

الكود بيرجع رتبة اللاعب ولو مامعه رتبة من الجدول بيرجع 

"Player"

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...