Forum

> > CS2D > Scripts > It isnt working lua?
Forums overviewCS2D overview Scripts overviewLog in to reply

English It isnt working lua?

12 replies
To the start Previous 1 Next To the start

old It isnt working lua?

phalenkO
User Off Offline

Quote
It isnt working Lua, why?

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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
Admin = {142925}
Mod = {}
VIP = {}
------------------FOR MOD-------------------------
addhook("say","kick")
function kick(id,txt)
if player(id,"usgn") == Mod[i] then
if string.sub(txt, 1, 5) == "!kick" then
local adam = string.sub(txt 7, 8)
parse("kick "..adam.." Kicked")
msg("©255000255"..(player(kid,"name")).."©255255255 "Kicked, By "©255000255"..(player(id,"name")).." ")
return 1
if string.sub(txt, 1, 5) == "!ban" then  
local adam = string.sub(txt, 6, 7)
parse("banname "..adam.." Banned")
msg("©255000255"..(player(bid,"name")).."©255255255 "Banned, By "©255000255"..(player(id,"name")).." ")
return 1
if string.sub(txt, 1, 5) == "!map" then
local adam = string.sub(txt, 5, 6)
parse("map "..map)
msg("©255000255"..(player(map,"name")).."©255255255 "Change Map, By "©255000255"..(player(id,"name")).." ")
return 1
if string.sub(txt, 1, 5) == "!slap" then
local adam = string.sub(txt, 4, 5)
parse("slap "..adam)
msg("©255000255"..(player(sid,"name")).."©255255255 "Slapped, By "©255000255"..(player(id,"name")).." ")
return 1
if string.sub(txt, 1, 5) == "!restart" then
local adam = string.sub(txt, 3, 4)
parse("restart")
return 1
end
end
end
end
end
end

-------------------FOR VIP-----------------------

addhook("say","kick")
function kick(id,txt)
if player(id,"usgn") == VIP[i] then 
if string.sub(txt, 1 ,5) == "!kick" then 
local adam = string.sub(txt, 7, 8)
parse("kick "..adam.." Kicked")
msg("©255000255"..(player(kid,"name")).."©255255255 "Kicked, By "©255000255"..(player(id,"name")).." ")
return 1
if string.sub(txt, 1 ,5) == "!slap" then 
local adam = string.sub(txt, 6, 7)
parse("slap "..adam)
msg("©255000255"..(player(sid,"name")).."©255255255 "Slapped, By "©255000255"..(player(id,"name")).." ")
return 1
if string.sub(txt, 1 ,5) == "!restart" then
local adam = string.sub(txt, 4 ,5)
parse("restart")
end
end
end
end
end

----------------FOR Admin-----------------------

addhook("say","kick")
function kick(id,txt)
if player(id,"usgn") == Admin[i] then 
if string.sub(txt, 1 ,5) == "!kick" then
local adam = string.sub(txt, 7, 8)
parse("kick "..adam.." Kicked")
msg("©255000255"..(player(kid,"name")).."©255255255 "Kicked, By "©255000255"..(player(id,"name")).." ")
return 1
if string.sub(txt, 1, 5) == "!ban" then
local adam = string.sub(txt, 6, 7)
parse("banname "..adam.." Banned")
msg("©255000255"..(player(bid,"name")).."©255255255 "Banned, By "©255000255"..(player(id,"name")).." ")
return 1
if string.sub(txt, 1, 5) == "!map" then  
local adam = string.sub(txt, 5, 6)
parse("map "..map)
msg("©255255255" Change Map, By "©255000255 "..(player(id,"name")).." ")
return 1
if string.sub(txt, 1, 5) == "!restart" then
local adam = string.sub(txt, 4 , 5)
parse("restart")
return 1
if string.sub(txt, 1, 5) == "!kill" then
local adam = string.sub(txt, 3, 4) 
parse("killplayer "..adam)
msg("©255000255"..(player(kid,"name")).."©255255255 "Killed, By "©255000255"..(player(id,"name")).." ")
return 1
if string.sub(txt, 1, 5) == "!slap" then 
local adam = string.sub(txt, 2, 3)
parse("slap "..adam)
msg("©255000255"..(player(sid,"name")).."©255255255 "Slapped,By "©255000255"..(player(id,"name")).." ")
return 1
end
end
end
end
end
end
end
end
end

addhook("say", "rankSay")
function rankSay(id, text)
if player(id,"usgn") == Admin[i] then 
msg("©255255255"..(player(id,"name")).." ©250000250»Admin«©255255255 : "..txt)
return 1
end 
end
if player(id,"usgn") == Mod[i] then
msg("©255255255"..(player(id,"name")).."©250000000»Moderator«©255255255 : "..txt)
return 1 
end
if player(id,"usgn") == VIP[i] then 
msg("©255255255"..(player(id,"name")).."©000250000»VIP«©255255255 : "..txt)
return 1 
end

old Re: It isnt working lua?

Yates
Reviewer Off Offline

Quote
IMG:https://i.imgur.com/caJIczN.png


What is
i
in
Mod[i]
?

Why is there a space in
string.sub(txt 7, 8)
between
txt
and
7
?

Where is
kid
defined?

This:
1
msg("©255000255"..(player(kid,"name")).."©255255255 "Kicked, By "©255000255"..(player(id,"name")).." ")
Will just not work at all. The use of quotes is completely wrong.

You have defined the function
kick
∗ > -> three times <- < ∗

flame T H R E E ( 3 ) T I M E S ( × ) flame

old Re: It isnt working lua?

phalenkO
User Off Offline

Quote
@user Yates: I looked at the gaps between 7 and 8 from another lua. I do not know anything about
1
string.sub (txt, 7, 8)
so I did something like that and I can not reach the picture site you are sharing. Please give me another link?
edited 1×, last 30.05.18 01:25:58 pm

old Re: It isnt working lua?

Quattro
GAME BANNED Off Offline

Quote
Begin by small steps, phalenk0

First make a test line to make sure you got the basics right. Then try adding a second command and so on...

And you should learn what hook does - it is just a way to start your function. You don't need to hook same action many times!

You want several say commands? Do this:

1
2
3
4
5
6
7
8
9
10
11
12
13
admin=100
vip=200
addhook("say","test")

function test(id,txt)
	if player(id,"usgn")==admin and txt=="test" then
		msg2(id,'you have typed test in chat and you are admin :D')
	end

	if player(id,"usgn")==vip and txt=="apple" then
		msg2(id,'you have typed apple in chat ad you are vip :D')
	end
end

old Re: It isnt working lua?

phalenkO
User Off Offline

Quote
user Quattro has written
I tried to do it like yours, but it did not
1
2
3
4
5
6
7
8
9
10
11
12
13
why = {142925}
who ={} 

addhook("say","adminlist")
function adminlist(id,txt)
     if player(id,"usgn")==why and txt== "xdd" then 
	     msg2(id,"Some more ABSURD")
	 end
	
	 if player(id,"usgn")==who and txt== "xd" then
	     msg2(id,"ABSURD")
     end
end

old Re: It isnt working lua?

Bowlinghead
User Off Offline

Quote
You compare a number with a table. Actually there is a red error code. Its always useful to copy it and post into the forum even on small scripts like yours :3

Delete {, } or do a loop for all values

old Re: It isnt working lua?

Talented Doge
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
13
why = {142925}
who ={} 

addhook("say","adminlist")
function adminlist(id,txt)
     if player(id,"usgn")==why and txt== "xdd" then 
          msg2(id,"Some more ABSURD")
      end
     
      if player(id,"usgn")==who and txt== "xd" then
          msg2(id,"ABSURD")
     end
end

Comparing a number with a table will definitely not work.

And rather than putting different ranks in different table I would put them all in one table and give them different values. Like VIP = 1 and Admin = 2. This is called a 2-dimensional array.

old Re: It isnt working lua?

Yates
Reviewer Off Offline

Quote
user Talented Doge has written
And rather than putting different ranks in different table I would put them all in one table and give them different values. Like VIP = 1 and Admin = 2. This is called a 2-dimensional array.

This doesn't even make sense.

old Re: It isnt working lua?

Yates
Reviewer Off Offline

Quote
user Talented Doge has written
And rather than putting different ranks in different table I would put them all in one table and give them different values. Like VIP = 1 and Admin = 2. This is called a 2-dimensional array.


1
2
3
4
ranks = {
	VIP = 1,
	Admin = 2
}

What you described doesn't make sense. How would this help?

old Re: It isnt working lua?

Yates
Reviewer Off Offline

Quote
You didn't even mention players, no need to get all salty about it

The italic text was to rewrite what was misunderstood by the way.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview