Forum

> > CS2D > Scripts > replacing some string
Forums overviewCS2D overview Scripts overviewLog in to reply

English replacing some string

2 replies
To the start Previous 1 Next To the start

old replacing some string

MikuAuahDark
User Off Offline

Quote
hi. i want create new lua with string.gsub for example:
1
if string.find(txt,"ping(id)") then code
the code is like this:
ping(id) replaced with playerping. his txt before say is this for example:
1
Idlers ping is ping(id) ms
and it returns like this:
1
Idlers ping is 273 ms
so ping(id) is replaced with 273
create me the script please

old Re: replacing some string

Starkkz
Moderator Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
function idleTime()
	return tonumber(game("mp_idletime"))
end

function showPings()
	for _, id in pairs(player(0,"table")) do
		if (player(id,"idle") or 0) > idleTime() then
			msg( string.gsub("Idlers ping is ping(id)", "ping(id)", player(id,"ping")))
		end
	end
end

Try to use it, you may call showPings function

Edit: sorry, I haven't noticed that your name was "Idlers" so I made it for idle players

old Re: replacing some string

MikuAuahDark
User Off Offline

Quote
@user Starkkz: but if the message is diffrent just like this?
1
ping(id) ms ping is the best
bdw my think is ping(id) is check player ping(not who say that message) so is just like this
Idlers ID is 1 and ping 575
Rian2 ID is 2 and ping 121
Idlers want message like this
1
Rian2 ping is ping(2)
it return like this
1
Rian2 ping is 121
sorry for the bad description
edited 1×, last 23.10.11 01:46:08 pm
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview