Forum

> > CS2D > Scripts > Rp Lua
Forums overviewCS2D overview Scripts overviewLog in to reply

English Rp Lua

4 replies
To the start Previous 1 Next To the start

old Rp Lua

Slayerwllpku
User Off Offline

Quote
Anything wrong with this lua?


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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
admin_usgn = {46944,46805,8027,14804,47093,46109,31966,13218,27167} 

addhook("team","adminteam") 
function adminteam(id,team) 
     if team == 1 then --if t
          for index,USGN in ipairs(admin_usgn) do 
               if player(id,"usgn") == 46944 or player(id,"usgn") == 46805 or player(id,"usgn") == 14804 or player(id,"usgn") == 47093 or player(id,"usgn") == 46109 or player(id,"usgn") == 31966 or player(id,"usgn") == 13218 or player(id,"usgn") == 27167 then 
                    return 0
               else 
                    return 1
               end 
          end 
     end 
end

Admin Commands
!a - teleport forward
!b - broadcast to server with name
!c - teleport player to you
!d - broadcast to server without name
!e - explosion
!i - spawn item
!h - heal player
!k - kick Player(by 
!l - run lua script (expensive)
!n - return npc position
!o - return tile position
!p - return position
!q - earthquake
!s - speedmod
!t - teleport you to player
!u - shutdown
!v - save server
!x - ban Player 
!deposit - put money to Bank-account 
!withdraw - get money from Bank-account 
!hudposition - set special-Hud position 
]]
addhook('say','adminCommands',-1)
function adminCommands(id,words)
     if isAdmin(id) and words:sub(1,1) =='!' then
          local command = words:lower():sub(2,2)
          if words:sub(3,3) ~= ' ' and #words ~= 2 then return end
          print(player(id,'name')..' used a command:'..words)
          if command == 'k' then
               kick=tonumber(words:sub(3,5))
               msg("©255255255"..(player(kick,"name")).." has been kicked by "..(player(id,"name")).."@C")
               parse("kick "..kick)
               return 1
          elseif command == 'x' then
               b=tonumber(string.sub(words,3,5))
               msg("©255255255"..(player(b,"name")).." has been banned by "..(player(id,"name")).."@C")
               parse("banname "..b)
               return 1
          elseif command =='a' then
               local distance = tonumber(words:sub(4))
               if distance then
                    local rot = math.rad(player(id,'rot')-180)
                    local x, y = -math.sin(rot)*distance*32, math.cos(rot)*distance*32
                    parse('setpos '..id..' '..player(id,'x')+x..' '..player(id,'y')+y)
               else
                    msg2(id,'Teleport forward: "!a <distance>"')
               end
               return 1
          elseif command =='b' then
               msg('©255100100'..player(id,'name')..' : '..words:sub(4)..'@C')
               return 1
          elseif command =='c' then
               local target = tonumber(words:sub(4))
               if target then
                    if player(target,'exists') then
                         if target == id then
                              msg2(id,'You may not teleport to yourself!')
                         end
                         parse('setpos '..target..' '..player(id,'x')..' '..player(id,'y'))
                         return 1
                    end
               end
               msg2(id,'Teleport a player to you: "!c <targetid>"')
               return 1
          elseif command =='d' then
               msg('©255100100'..words:sub(4)..'@C')
               return 1
          elseif command =='e' then
               local dmg = tonumber(words:sub(4))
               if dmg then
                    parse('explosion '..player(id,'x')..' '..player(id,'y')..' '..dmg..' '..dmg..' '..id)
                    return 1
               end
               msg2(id,'Spawn explosion: "!e <dmg>"')
               return 1
          elseif command =='i' then
               local itemid = tonumber(words:sub(4))
               if itemid then
                    additem(id,itemid)
                    return 1
               end
               msg2(id,'Spawn item: "!i <itemid>"')
               return 1
          elseif command =='h' then
               local s = words:find(' ',4)
               local target = tonumber(words:sub(4,s))
               if target then
                    if player(target,'exists') then
                         local heal = s and tonumber(words:sub(s+1,words:find(' ',s+1))) or nil
                         if heal then
                              parse('explosion '..player(target,'x')..' '..player(target,'y')..' 1 '..(-heal))
                              return 1
                         end
                    end
               end
               msg2(id,'Heal player: "!h <targetid> <amount>"')
               return 1
          elseif command =='l' then
               local script = words:sub(3)
               if script then
                    msg2(id,tostring(assert(loadstring(script))() or 'done!'))
                    return
               end
               msg2(id,'Run lua script: "!l <script>"')
               return 1
          elseif command =='n' then
               msg2(id,'{'..player(id,'tilex')*32+16 ..', '..player(id,'tiley')*32+16 ..'}')
               return 1
          elseif command =='o' then
               msg2(id,'{'..player(id,'tilex')..', '..player(id,'tiley')..'}')
               return 1
          elseif command =='p' then
               msg2(id,'{'..player(id,'x')..', '..player(id,'y')..'}')
               return 1
          elseif command =='q' then
               local length = tonumber(words:sub(3))
               if length then
                    length = math.min(length*50,250)
                    for _, id in ipairs(player(0,'table')) do
                         parse('shake '..id..' '..length)
                    end
                    for i = 1, 6 do
                         if math.random(0,1) == 1 then
                              parse('sv_sound weapons/explode'..i..'.wav')
                         end
                    end
               else
                    msg2(id,'Earthquake: "!q <length in seconds, max 5>"')
               end
               return 1
          elseif command =='s' then
               local s = words:find(' ',4)
               local target = tonumber(words:sub(4,s))
               if target then
                    if player(target,'exists') then
                         local speed = s and tonumber(words:sub(s+1,words:find(' ',s+1))) or nil
                         if speed then
                              parse('speedmod '..target..' '..speed)
                              return 1
                         end
                    end
               end
               msg2(id,'Speed modifier: "!s <targetid> <speedmod, between -100 and 100>"')
               return 1
          elseif command =='t' then
               local target = tonumber(words:sub(3))
               if target then
                    if player(target,'exists') then
                         if target == id then
                              msg2(id,'You may not teleport to yourself!')
                         end
                         parse('setpos '..id..' '..player(target,'x')..' '..player(target,'y'))
                         return 1
                    end
               end
               msg2(id,'Teleport to player: "!t <targetid>"')
               return 1
          elseif command =='u' then
               local delay = tonumber(words:sub(3)) or 0
               shutdown(delay*1000)
               return 1
          elseif command =='v' then
               saveserver()
               msg2(id,'Saved server!')
               return 1
          end
     end
end

old Re: Rp Lua

GreenDevil
User Off Offline

Quote
Try this:
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
admin_usgn = {46944,46805,8027,14804,47093,46109,31966,13218,27167}

addhook("team","adminteam")
function adminteam(id,team)
if (team == 1) then --if t
for index,USGN in ipairs(admin_usgn) do
if (player(id,"usgn") == 46944) or (player(id,"usgn") == 46805) or (player(id,"usgn") == 14804) or (player(id,"usgn") == 47093) or (player(id,"usgn") == 46109) or (player(id,"usgn") == 31966) or (player(id,"usgn") == 13218) or (player(id,"usgn") == 27167) then
return 0
else
return 1
end
end
end
end

Admin Commands
!a - teleport forward
!b - broadcast to server with name
!c - teleport player to you
!d - broadcast to server without name
!e - explosion
!i - spawn item
!h - heal player
!k - kick Player(by
!l - run lua script (expensive)
!n - return npc position
!o - return tile position
!p - return position
!q - earthquake
!s - speedmod
!t - teleport you to player
!u - shutdown
!v - save server
!x - ban Player
!deposit - put money to Bank-account
!withdraw - get money from Bank-account
!hudposition - set special-Hud position
]]
addhook("say","admincommands")
function admincommands(id,words)
if isAdmin(id) and words:sub(1,1) =='!' then
local command = words:lower():sub(2,2)
if words:sub(3,3) ~= ' ' and #words ~= 2 then return end
print(player(id,'name')..' used a command:'..words)
if command == 'k' then
kick=tonumber(words:sub(3,5))
msg("©255255255"..(player(kick,"name")).." has been kicked by "..(player(id,"name")).."@C")
parse("kick "..kick)
return 1
elseif command == 'x' then
b=tonumber(string.sub(words,3,5))
msg("©255255255"..(player(b,"name")).." has been banned by "..(player(id,"name")).."@C")
parse("banname "..b)
return 1
elseif command =='a' then
local distance = tonumber(words:sub(4))
if distance then
local rot = math.rad(player(id,'rot')-180)
local x, y = -math.sin(rot)*distance*32, math.cos(rot)*distance*32
parse('setpos '..id..' '..player(id,'x')+x..' '..player(id,'y')+y)
else
msg2(id,'Teleport forward: "!a <distance>"')
end
return 1
elseif command =='b' then
msg('©255100100'..player(id,'name')..' : '..words:sub(4)..'@C')
return 1
elseif command =='c' then
local target = tonumber(words:sub(4))
if target then
if player(target,'exists') then
if target == id then
msg2(id,'You may not teleport to yourself!')
end
parse('setpos '..target..' '..player(id,'x')..' '..player(id,'y'))
return 1
end
end
msg2(id,'Teleport a player to you: "!c <targetid>"')
return 1
elseif command =='d' then
msg('©255100100'..words:sub(4)..'@C')
return 1
elseif command =='e' then
local dmg = tonumber(words:sub(4))
if dmg then
parse('explosion '..player(id,'x')..' '..player(id,'y')..' '..dmg..' '..dmg..' '..id)
return 1
end
msg2(id,'Spawn explosion: "!e <dmg>"')
return 1
elseif command =='i' then
local itemid = tonumber(words:sub(4))
if itemid then
additem(id,itemid)
return 1
end
msg2(id,'Spawn item: "!i <itemid>"')
return 1
elseif command =='h' then
local s = words:find(' ',4)
local target = tonumber(words:sub(4,s))
if target then
if player(target,'exists') then
local heal = s and tonumber(words:sub(s+1,words:find(' ',s+1))) or nil
if heal then
parse('explosion '..player(target,'x')..' '..player(target,'y')..' 1 '..(-heal))
return 1
end
end
end
msg2(id,'Heal player: "!h <targetid> <amount>"')
return 1
elseif command =='l' then
local script = words:sub(3)
if script then
msg2(id,tostring(assert(loadstring(script))() or 'done!'))
return
end
msg2(id,'Run lua script: "!l <script>"')
return 1
elseif command =='n' then
msg2(id,'{'..player(id,'tilex')*32+16 ..', '..player(id,'tiley')*32+16 ..'}')
return 1
elseif command =='o' then
msg2(id,'{'..player(id,'tilex')..', '..player(id,'tiley')..'}')
return 1
elseif command =='p' then
msg2(id,'{'..player(id,'x')..', '..player(id,'y')..'}')
return 1
elseif command =='q' then
local length = tonumber(words:sub(3))
if length then
length = math.min(length*50,250)
for _, id in ipairs(player(0,'table')) do
parse('shake '..id..' '..length)
end
for i = 1, 6 do
if math.random(0,1) == 1 then
parse('sv_sound weapons/explode'..i..'.wav')
end
end
else
msg2(id,'Earthquake: "!q <length in seconds, max 5>"')
end
return 1
elseif command =='s' then
local s = words:find(' ',4)
local target = tonumber(words:sub(4,s))
if target then
if player(target,'exists') then
local speed = s and tonumber(words:sub(s+1,words:find(' ',s+1))) or nil
if speed then
parse('speedmod '..target..' '..speed)
return 1
end
end
end
msg2(id,'Speed modifier: "!s <targetid> <speedmod, between -100 and 100>"')
return 1
elseif command =='t' then
local target = tonumber(words:sub(3))
if target then
if player(target,'exists') then
if target == id then
msg2(id,'You may not teleport to yourself!')
end
parse('setpos '..id..' '..player(target,'x')..' '..player(target,'y'))
return 1
end
end
msg2(id,'Teleport to player: "!t <targetid>"')
return 1
elseif command =='u' then
local delay = tonumber(words:sub(3)) or 0
shutdown(delay*1000)
return 1
elseif command =='v' then
saveserver()
msg2(id,'Saved server!')
return 1
end
end
end

I don't know if this will fix that but you can try it

old Re: Rp Lua

DannyDeth
User Off Offline

Quote
It's very simple:
Your comments are being proccessed as actual code, and so Lua stops right where it sees a load of crap starting with "!". Remove it and it will probably work.

old Re: Rp Lua

DannyDeth
User Off Offline

Quote
You can't, it's complete bullshit and won't work.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview