Forum

> > CS2D > Scripts > Warning player. lua script
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Warning player. lua script

9 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Warning player. lua script

muxarus
User Off Offline

Zitieren
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
2× editiert, zuletzt 03.03.15 15:45:53

alt Re: Warning player. lua script

Bowlinghead
User Off Offline

Zitieren
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!

alt Re: Warning player. lua script

Rainoth
Moderator Off Offline

Zitieren
@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)

alt Re: Warning player. lua script

muxarus
User Off Offline

Zitieren
user Rainoth hat geschrieben
@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
Zitat
banusgn 2 1 testing
in console)
user Rainoth hat geschrieben
@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
1× editiert, zuletzt 03.03.15 19:33:05

alt Re: Warning player. lua script

Rainoth
Moderator Off Offline

Zitieren
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.
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht