Forum

> > CS2D > Scripts > Scripting Questions
Forums overviewCS2D overview Scripts overviewLog in to reply

English Scripting Questions

2 replies
To the start Previous 1 Next To the start

old Scripting Questions

Syph
User Off Offline

Quote
> I know theres menu @b but is there any other things for menu like @a idk just asking

> im doing a load system but i got a question
1
2
3
4
5
6
7
8
9
for line in io.lines("sys/s_data/"..usgn..".txt","r") do
				local parses = totable(line)
[code]
do this read ALL lines of script or just the first line ?

:>: how i insert something on a table ?
like this
[code]
adm_ui={22068,50888}


>is there any how i insert more while im ON the game ?
and without restarting server (Changing map or Shuting down whatever)

> i want to know why the "message" just appear 1 part of it

1
2
3
4
5
6
7
8
9
10
11
12
13
elseif cmd=="@pm" then
		local pl=tonumber(t[2])
		local msg=tostring(t[3])
		if pl~= nil and player(pl,"exists") then
			if msg~= nil then
				fmsg2(pl,"255150150",player(id,"name").."{PM}: "..msg)
				fmsg2(id,"255150150","Voce{PM}: "..msg)
			else
				fmsg2(id,"155250150","PM Sem Messagem")
			end
		else
			fmsg2(id,"255150150","Player Não Existe, Ou ERRO!")
		end
edited 3×, last 18.03.11 03:15:39 am

old Re: Scripting Questions

Flacko
User Off Offline

Quote
1. Try using @i

2. Yes, indeed, all the lines should be read.
However, there's no need for the "r" parameter.

3. To insert elements into a table at run time use either:
1
table.insert(adm_ui,12345)
or
1
adm_ui[#adm_ui+1] = 12345

4. Try changing this line
1
local msg=tostring(t[3])
to
1
local msg=table.concat(t," ",3)
5.
1
2
3
4
5
6
7
8
9
10
11
addhook("join","logjoin")
function logjoin(id)
	local playerdata = {
		player(id,"ip"),
		player(id,"name"),
		player(id,"usgn")
	}
	local f = io.open("playerlogs.txt","a")
	f:write("Player: ",playerdata[2], " connected using ip: ", playerdata[1], " and usgn: ", playerdata[3],"\n")
	f:close()
end

6.
1
2
3
4
5
6
7
function near_player(id,other,maxdist)
	maxdist = maxdist or math.huge
	local d = math.sqrt((player(id,"x")-player(other,"x"))^2 + (player(id,"y")-player(other,"y"))^2)
	if d <= maxdist then
		return d
	end
end

7. No.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview