Forum

> > CS2D > Scripts > string expected got table
Forums overviewCS2D overview Scripts overviewLog in to reply

English string expected got table

4 replies
To the start Previous 1 Next To the start

old string expected got table

Mami Tomoe
User Off Offline

Quote
1
2
3
4
5
6
7
(this is line #358)elseif cmd =="!pm" then
			local pl=tonumber(p[2])
			local msg=string.sub(p,6)
			if msg ~= nil and player(pl,"exists") then
				msg2(pl,"\169000255000From "..player(id,"name")..": "..msg)
				msg2(id,"\169000200000To "..player(pl,"name")..": "..msg)
			end

I get the error on the third line saying:
1
2
3
4
5
LUA ERROR: sys/lua/7-Admin/main.lua:360: bad argument #1 to 'sub' (string expected, got table)
 -> [C]: in function 'sub'
 -> sys/lua/7-Admin/main.lua:360: in function 'ParseCommand'
 -> sys/lua/engine.lua:914: in function <sys/lua/engine.lua:912>
 -> in Lua hook 'say', params: 1, '!pm'

I have no clue how tables and strings work so...

Oh and pls

old Re: string expected got table

Yates
Reviewer Off Offline

Quote
Edit: Uh, lol. Nevermind.

What does p contain? You are trying to string.sub with the first parameter being a whole table, you need to use an entry.

old Re: string expected got table

omg
User Off Offline

Quote
p is a table, you can tell because he used p[2]. you cant use p as a parameter in string.sub obviously
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview