Forum

> > CS2D > Scripts > Warning player. lua script
Forums overviewCS2D overview Scripts overviewLog in to reply

English Warning player. lua script

9 replies
To the start Previous 1 Next To the start

old Warning player. lua script

muxarus
User Off Offline

Quote
Hi us nrealSoftWare! I want to make warnings script to warn players who broken my server rules but its not working. so there is code:
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
addhook("say","_say")
function _say(id,txt)
if string.sub(txt,1,6)=="!warn " then
	local iid2 = string.sub(txt,7)
	warn_func_r(id,iid2)
	return 1
end
end
warn_func={}

function warn_func_r(id,iid2)
if player(iid2,"exists") then
if warn_func[iid2]==nil then warn_func[iid2]=0 end
if warn_func[iid2]==0 then 
msg("Player "..player(iid2,"name").." has been warned!")
warn_func[iid2]=1

elseif warn_func[iid2]==1 then 
msg("Player "..player(iid2,"name").." has been warned!")
warn_func[iid2]=2

elseif warn_func[iid2]==2 then 
msg("Player "..player(iid2,"name").." KICKED! (REASON: WARNS: 3)")
parse("kick "..iid2.." 'WARNS: 3'")
warn_func[iid2]=3

elseif warn_func[iid2]==3 then 
msg("Player "..player(iid2,"name").." USGN BANNED! (REASON: WARNS: 4) ")
parse("banusgn "..iid2.." 30")
warn_func[iid2]=0
end
end
end
NOTE: i dont know why its not working normally
edited 2×, last 03.03.15 03:45:53 pm

old Re: Warning player. lua script

Bowlinghead
User Off Offline

Quote
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
addhook("say","_say")
function _say(id,txt)
	if string.sub(txt,1,6)=="!warn " then
     		local iid2 = string.sub(txt,7)
     		warn_func_r(id,iid2)
    		return 1
	end
end -- <-- "end" was missing?

warn_func={}

function warn_func_r(id,iid2)
	if player(iid2,"exists") then
		if warn_func[iid2]==nil then warn_func[iid2]=0 end
		if warn_func[iid2]==0 then 
			msg("Player "..player(iid2,"name").." has been warned!")
			warn_func[iid2]=1
		elseif warn_func[iid2]==1 then 
			msg("Player "..player(iid2,"name").." has been warned!")
			warn_func[iid2]=2

		elseif warn_func[iid2]==2 then 
			msg("Player "..player(iid2,"name").." KICKED! (REASON: WARNS: 3)")
			parse("kick "..iid2.." 'WARNS: 3'")
			warn_func[iid2]=3

		elseif warn_func[iid2]==3 then 
			msg("Player "..player(iid2,"name").." USGN BANNED! (REASON: WARNS: 4) ")
			parse("banusgn "..iid2.." 30")
			warn_func[iid2]=0
		end
	end
end

The console should show you the error!

old Re: Warning player. lua script

Rainoth
Moderator Off Offline

Quote
@user muxarus:
Add
1
msg("1")
and 2 and 3 and so on for every IF then see if it meets all conditions.

P.S. in usgn ban you're using iid2 in ban command when it should be usgn ID (not regular ID)

old Re: Warning player. lua script

muxarus
User Off Offline

Quote
user Rainoth has written
@user muxarus:
P.S. in usgn ban you're using iid2 in ban command when it should be usgn ID (not regular ID)
but i tested it and result: player has been banned on my server :c (im tested command
Quote
banusgn 2 1 testing
in console)
user Rainoth has written
@user muxarus:
Add
1
msg("1")
and 2 and 3 and so on for every IF then see if it meets all conditions.
but every IF working, i have only one problem: variable
1
warn_func[iid2]
won't set to anything
edited 1×, last 03.03.15 07:33:05 pm

old Re: Warning player. lua script

Rainoth
Moderator Off Offline

Quote
did you check it how I told you to see if every IF was working or do you just believe that every IF is working.

About the banusgn. I don't know, it just seems logical to use usgn when you're banning by usgn, not player id.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview