English Warning player. lua script

9 replies
Goto Page
To the start Previous 1 Next To the start
03.03.15 10:53:45 am
Up
muxarus
User
Offline Off
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:
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
IMG:http://steamsignature.com/status/german/76561198081961553.png
IMG:http://steamsignature.com/AddFriend.png
03.03.15 11:24:53 am
Up
Bowlinghead
User
Offline Off
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 -- <-- "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!
Share time limited free games here
03.03.15 11:58:37 am
Up
Talented Doge
User
Offline Off
basically...
if you used an "if", please give it an "end"...
Talented Doge
03.03.15 03:06:32 pm
Up
muxarus
User
Offline Off
@user Talented Doge: This is out of place.
Did you even think what you wrote?

@user Bowlinghead: i have no errors in console. variable
Code:
1
warn_func[iid2]
won't set to anything
IMG:http://steamsignature.com/status/german/76561198081961553.png
IMG:http://steamsignature.com/AddFriend.png
03.03.15 05:22:00 pm
Up
Rainoth
Moderator
Offline Off
@user muxarus:
Add
Code:
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)
03.03.15 06:59:51 pm
Up
muxarus
User
Offline Off
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
Code:
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
Code:
1
warn_func[iid2]
won't set to anything
edited 1×, last 03.03.15 07:33:05 pm
IMG:http://steamsignature.com/status/german/76561198081961553.png
IMG:http://steamsignature.com/AddFriend.png
03.03.15 07:56:12 pm
Up
Rainoth
Moderator
Offline Off
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.
03.03.15 10:21:51 pm
Up
muxarus
User
Offline Off
@user Rainoth: yes, i've checked all IF and they works.
edited 1×, last 04.03.15 10:38:15 am
IMG:http://steamsignature.com/status/german/76561198081961553.png
IMG:http://steamsignature.com/AddFriend.png
04.03.15 12:16:19 pm
Up
MikuAuahDark
User
Offline Off
iid2 is string. Convert it to number first at line 5
Code:
warn_func_r(id,tonumber(iid2))
Hello? Are you there, Tae Hanazono?
04.03.15 01:53:33 pm
Up
muxarus
User
Offline Off
@user MikuAuahDark: Yay! it works! thank you very much! thanks!
IMG:http://steamsignature.com/status/german/76561198081961553.png
IMG:http://steamsignature.com/AddFriend.png
To the start Previous 1 Next To the start