Forum

> > CS2D > Scripts > Set Commands Permissions
Forums overviewCS2D overview Scripts overviewLog in to reply

English Set Commands Permissions

6 replies
To the start Previous 1 Next To the start

old Set Commands Permissions

Man Of Steel
User Off Offline

Quote
Hi everyone,

Actually i came here for ask some help and i hope Somebody will help me.

Guys, i have some commands and i want to add these commands in hc admin script. actually i'm using different way for add commands in hc and really its soo easy i know how to add commands and commands works always.

But i just want add permissions, i mean Moderators/Admins cannot kill to each other, they can kill only v.i.p and users, i want if mods/admins mistakenly use punish command to other staff so msg show
" You Cannot Kill Staff members"


Spoiler >


Please help me for this, i'm really very happy if anybody will help and much appreciate
edited 1×, last 02.07.18 01:52:55 pm

old Re: Set Commands Permissions

Rainoth
Moderator Off Offline

Quote
Make a variable that separates the ranks (for example, admin rank is 100, mod is 50, vip is 20 and so on)

When you see someone typing a command (in your case with !) check:
If user can use the command
If target's rank is lower than users

old Re: Set Commands Permissions

KingShadow
User Off Offline

Quote
use
1
if pl[id].lvl >= <ranklvl> then

Admin:15
Senior Moderator:10
Moderator:5
VIP:3
user. :1

if command for lvl 5 or any level the higher rank can use it

example:!kick for moderator also senior moderator and admin can use it

Spoiler >
edited 4×, last 03.07.18 08:48:15 pm

old Re: Set Commands Permissions

Rainoth
Moderator Off Offline

Quote
@user KingShadow: You just added numeric ranks to commands. That's not what he's asking for. He wants commands to impact only people with lower ranks than the user of commands.

old Re: Set Commands Permissions

Rainoth
Moderator Off Offline

Quote
I'm not going to write you everything, I can make you a good base for it, though.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
commands = {
	player = {},
	hooks = {"say","join"},
	users = {
		[100] = {11111}, -- E.g. Admin
		[50] = {1234,12345}, -- Moderators
		[10] = {9999, 12333, 22, 8886} -- VIPs
	},
	cmd = {
	["kick"] = {
		type = "player",
		level = 50,
		description = "Kicks a player",
		func = function(id)
			parse("kick "..id)
		end},
	["slap"] = {
		type = "player",
		level = 10,
		description = "Slaps a player",
		func = function(id)
			parse("slap "..id)
		end},
	["ban"] = {
		type = "player",
		level = 100,
		description = "IP bans a player",
		func = function(id)
			parse("banip "..player(id,"ip"))
		end}
	}
}
for k,v in pairs (commands.hooks) do
	addhook(v,"_"..v)
end

function _join(id)
	commands.player[id] = {}
	if player(id,"usgn") > 0 then
		for _,v in pairs (commands.users) do
			for rank,usgn in pairs (v) do
				if player(id,"usgn") == v then
					commands.player[id].ranking = rank
				end
			end
		end
	end
end

function _say(id, txt)
	say = txt:split()
	if say[1]:sub(1,1) == "!" then
		for k,v in pairs(commands.cmd) do
			if k == say[1]:sub(2,#say[1]) then
				if commands.player[id].ranking >= v.level then
					if v.type == "player" and tonumber(say[2]) then
						if commands.player[id].ranking > commands.player[tonumber(say[2])].ranking then
							v.func(tonumber(say[2])
						else
							msg2(id,"Target outranks you.")
						end
					else
						v.func(tonumber(say[2])
					end
				else
					msg2(id,"Insufficient rank.")
				end
			end
		end
		return 1
	end			
end

function string.split(str,pat) -- Splitting strings (sentences) into separate words
    local t = {}
    for word in string.gmatch(str,pat or "[^%s]+") do
        t[#t+1] = word
    end
    return t
end

Something like this. Mind I didn't test it and if I was making it for myself, I'd elaborate it way more.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview