Forum

> > CS2D > Scripts > triggerentity triggering multiple times
Forums overviewCS2D overview Scripts overviewLog in to reply

English triggerentity triggering multiple times

3 replies
To the start Previous 1 Next To the start

old triggerentity triggering multiple times

Blighted Song
User Off Offline

Quote
Im haveing a problem with my trigger entity hook, whenever it goes off it happens 10 times and I'm really not sure why.

Heres the repeated code
1
2
3
4
5
6
7
8
9
10
11
12
addhook("triggerentity","actions")
function actions(x,y)
	i=0
	var1=entity(x,y,"name")
	var2=string.sub(var1, -3,-1)
	var2=0
	while i<#var1 do
		print(i)
		i=i+1
	end

end
I'm just testing some shit and it started repeating, also the trigger is a trigger_move entity and is only triggering once as far as I can tell. This is also the only point of referance for the actions function.

This is probably just an oversight on my part but i can't work out what it is.

old Re: triggerentity triggering multiple times

DannyDeth
User Off Offline

Quote
'var1' isn't a table, it's a string. lol. It isn't triggering multiple times, the code's just printing the number to 10 because the name is probably 10 chars long. Also, 'i' isn't initalized so it should also be giving an 'attempt to perform arithmetic on nil value' error as well. Also, I'd like to know why you are giving negative values to string.sub?

EDIT: Sorry, my mistake, 'i' is initialized.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview