Forum

> > CS2D > Scripts > Script Bug
Forums overviewCS2D overview Scripts overviewLog in to reply

English Script Bug

3 replies
To the start Previous 1 Next To the start

old Script Bug

light and gaia
User Off Offline

Quote
When I speak or write a command, an "A" comes out.
And also, if you only put the command (! Kick, for example), the kick message appears.

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
---------------------------------
------ Admin Script by TGT10 ------
------       71814         ------
---------------------------------

--BROADCAST--
addhook("say","broadcast") function broadcast(id,t)
     if string.sub(t,1,10) == "!broadcast" then
        local bt = string.sub(t,12)
        msg("©000255255"..player(id,"name").." ©000255255(BROADCAST): "..bt)
     end
end

ownerlist = {71814} ---OWNER
adminlist = {XXXXX} ---ADMIN
modlist = {XXXXX} ---MOD
viplist = {XXXXX} ---VIP

addhook("say" , "OWNERCMDS")
	function OWNERCMDS(id,message)
	for _, usgn in ipairs(ownerlist) do
		if player(id,'usgn') == usgn then
			if string.sub(message, 1, 5) == "!kick" then
				local tokick = string.sub(message, 7,8)
				local toreason = string.sub(message, 9)
				parse("kick "..tokick.." "..toreason)
					 msg("©000255000[SERVER]: ©192192192OWNER "..player(id,"name").." kicked a player. ©255050050Reason: "..toreason)
			end
			if string.sub(message, 1, 4) == "!ban" then
				local toban = string.sub(message, 6,7)
				local toreason2 = string.sub(message, 8)
				parse("ban "..toban.." "..toreason2)
					 msg("©000255000[SERVER]: ©192192192OWNER "..player(id,"name").." banned a player. ©255050050Reason: "..toreason2)
			end
		end
	end
end

addhook("say","OWNERCHAT")
function OWNERCHAT(id,txt)
		for _, usgn in ipairs(ownerlist) do
		if player(id,'usgn') == usgn then
        msg("©192192192[©255025025Owner©192192192] ©000255000"..player(id,"name").." : "..txt)
return 0
end
end
end

SS: http://imgur.com/a/wvVx7

old Re: Script Bug

VaiN
User Off Offline

Quote
the A character is because your script file is not UTF-8 format and contains the "©" character. replace that character with "\169" or string.char(169)

Edit: the command being output to chat is likely because you did not return 1 in your say hook to supress it.

Also, the excessive use of string.sub makes me want to vomit. just saying.

Edit Again: I should also recommend not using so many separate say hooks. Just put it all in one function.

old Re: Script Bug

GeoB99
Moderator Off Offline

Quote
The Code >

I'm in a hurry unfortunately so I did not take into consideration the pattern matching for capturing arguments of a command but you can do that yourself by reading thread cs2d [Tip] Stop using string.sub() for commands.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview