Forum

> > CS2D > Scripts > This script isn't work! :(
Forums overviewCS2D overview Scripts overviewLog in to reply

English This script isn't work! :(

7 replies
To the start Previous 1 Next To the start

old This script isn't work! :(

HedShot
User Off Offline

Quote
Hi all!

I want to create this script, but it doesn't work!
Help me PLS!

1
2
3
4
5
6
7
8
addhook("say","bsay")
addhook("sayteam","bsay")
function bsay(id,msgg)
	if (string.sub(msgg,1,10)=="!explosion" and player(id,"usgn")=="116544") then
		range = string.sub(msgg,12,100)
		parse("explosion "..player(id,"x").." "..player(id,"y").." "..range)
	end
end

old Re: This script isn't work! :(

VADemon
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
13
addhook("say","bsay")
addhook("sayteam","bsay")
function bsay(id,msgg)
	if (string.sub(msgg,1,10)=="!explosion" and player(id,"usgn")=="116544") then
		local range = string.sub(msgg,12) --is gonna go until the end of the string
		-- also make it a local variable

		local dmg = 32 --damage of explosion

		-- also you failed at parameters of the explosion command:
		parse("explosion "..player(id,"x").." "..player(id,"y").." "..range.." "..dmg.." "..id)
	end
end

cs2d cmd explosion

old Re: This script isn't work! :(

DarkBooy
User Off Offline

Quote
user VADemon has written
1
2
3
4
5
6
7
8
9
10
11
12
13
addhook("say","bsay")
addhook("sayteam","bsay")
function bsay(id,msgg)
	if (string.sub(msgg,1,10)=="!explosion" and player(id,"usgn")=="116544") then
		local range = string.sub(msgg,12) --is gonna go until the end of the string
		-- also make it a local variable

		local dmg = 32 --damage of explosion

		-- also you failed at parameters of the explosion command:
		parse("explosion "..player(id,"x").." "..player(id,"y").." "..range.." "..dmg.." "..id)
	end
end

cs2d cmd explosion



i try your code but... its not work ..

@user HedShot: this work (just say !explosion)
1
2
3
4
5
6
7
8
9
10
11
addhook("say","bsay")
addhook("sayteam","bsay")
function bsay(id,msgg)
	if (player(id,"usgn")==116544) then
     if string.sub(msgg,1,10)=="!explosion" then
          local range = string.sub(msgg,12) 
          local dmg = 32        
          parse("explosion "..player(id,"x").." "..player(id,"y").." "..range.." "..dmg.." "..id)
     end
     end
end

or ...

take this : (just say !e dmg)
This Code Is better >
edited 5×, last 29.03.13 03:46:15 pm

old Re: This script isn't work! :(

omg
User Off Offline

Quote
seriously? im no genius, but im pretty sure string:sub(2,2) is always an empty string or out of bounds. nice try, dark

old Re: This script isn't work! :(

Infinite Rain
Reviewer Off Offline

Quote
1
2
3
4
5
6
7
8
addhook("say","bsay")
addhook("sayteam","bsay")
function bsay(id,msgg)
     if (string.sub(msgg,1,10)=="!explosion" and player(id,"usgn")==116544) then
          range = string.sub(msgg,12)
          parse("explosion "..player(id,"x").." "..player(id,"y").." "..range.." 32 ".. id)
     end
end

Here you go, you had 2 mistakes:
1. player(id,"usgn")=="116544" - Wrong because player(id, 'usgn') will return the numeric(!) value.
2. range = string.sub(msgg,12,100) - You just need to do it like so: string.sub(msgg,12)

old thx

HedShot
User Off Offline

Quote
Thanks for all!
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview