Forum

> > CS2D > Scripts > Script with "Second"
Forums overviewCS2D overview Scripts overviewLog in to reply

English Script with "Second"

25 replies
Page
To the start Previous 1 2 Next To the start

old Script with "Second"

Kostyan1996
User Off Offline

Quote
Can you help me? This code:

1
2
3
4
5
6
addhook("second","time_npc")
function time_npc()
	if ((player(id,"x") >=63) and (player(id,"x") <=68) and (player(id,"y") >=28) and (player(id,"y") <=33)) then
		parse('spawnnpc 1 64 29 0')
	end
end

Wont work! Problem: When i launch map, game give me error "EXCEPTION_ACCESS_VIOLATION". But when i change hook "second" on hook "minute", map launch! BUT, when minute left, game crashes. Help please!

old Re: Script with "Second"

Jynxxx
User Off Offline

Quote
Why not take off this line
1
if ((player(id,"x") >=63) and (player(id,"x") <=68) and (player(id,"y") >=28) and (player(id,"y") <=33)) then
and just use this?
1
2
3
4
addhook("second","time_npc")
function time_npc()
	parse("spawnnpc 1 64 29 0")
end

old Re: Script with "Second"

Kostyan1996
User Off Offline

Quote
Because I need script, where zombie spawn only when player stay in area (63 to 68 - x and 28 to 33 - y).
---
So, do you know answer?
edited 2×, last 25.06.12 04:06:50 pm

old Re: Script with "Second"

Apache uwu
User Off Offline

Quote
Assuming that you mean "all players", simply place a loop to check all players within that area.

1
2
3
4
5
6
7
8
9
addhook("second","time_npc")
function time_npc()
	for _,id in pairs(player(0,"tableliving")) do
		if ((player(id,"x") >=63) and (player(id,"x") <=68) and (player(id,"y") >=28) and (player(id,"y") <=33)) then
			parse('spawnnpc 1 64 29 0')
			return
		end
	end
end

The return makes it so only 1 npc will spawn per second--guided that there is someone in that area, so if there are like 3 or 4 people in that are it will still only spawn once.

old Re: Script with "Second"

Apache uwu
User Off Offline

Quote
Oh, then remove the return.

1
2
3
4
5
6
7
8
addhook("second","time_npc")
function time_npc()
	for _,id in pairs(player(0,"tableliving")) do
		if ((player(id,"x") >=63) and (player(id,"x") <=68) and (player(id,"y") >=28) and (player(id,"y") <=33)) then
			parse('spawnnpc 1 64 29 0')
		end
	end
end

old Re: Script with "Second"

Kostyan1996
User Off Offline

Quote
Thanks, works now, but can you say, what means string " for _,id in pairs(player(0,"tableliving")) do"?

Because whenever I make script, it crashes game...
---
Eg. this:
1
2
3
4
5
6
7
8
9
10
11
12
13
addhook("trigger","combine_run1")

function combine_run1(combine.run1_1,0)
	parse('bot_add_ct')
	parse('bot_add_ct')
end

function combine_run1(combine.run1_2,0)
	parse('spawnplayer 2 336 176')
	parse('spawnplayer 3 370 170')
	parse('equip 2 69')
	parse('equip 3 69')
end

old Re: Script with "Second"

Kostyan1996
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
13
14
addhook("trigger","combine_run1.1")
addhook("trigger","combine_run1.2")

function combine_run1.1(combine.run1_1,0)
	parse('bot_add_ct')
	parse('bot_add_ct')
end

function combine_run1.2(combine.run1_2,0)
	parse('spawnplayer 2 336 176')
	parse('spawnplayer 3 370 170')
	parse('equip 2 69')
	parse('equip 3 69')
end

Like this? But it crashes again!

old Re: Script with "Second"

Alistaire
User Off Offline

Quote
user Kostyan1996 has written
But I need to check two different triggers: "combine.run1_1" and "combine.run1_2"!


Look. Every time you blink you must lift your right leg, and every time you blink you must lower your right leg.

----

1
2
3
4
5
6
7
8
9
10
11
12
13
addhook('trigger', 'AA_trigger')

function AA_trigger(trigger, source)
	if trigger == 'combine.run1_1' then
		parse('bot_add_ct')
		parse('bot_add_ct')
	elseif trigger == 'combine.run1_2' then
		parse('spawnplayer 2 336 176')
     		parse('spawnplayer 3 370 170')
      		parse('equip 2 69')
      		parse('equip 3 69')
	end
end

old Re: Script with "Second"

Kostyan1996
User Off Offline

Quote
Thanks man!
---
Need another help (sorry for my stupidness, I'm not good scripter yet)...

1
2
3
4
5
6
for i=2,3 do
			parse('bot_add_ct')
			parse('spawnplayer '..i..' 336 176')
			parse('equip '..i..' 74')
			parse('strip '..i..' 50')
		end

Must be: I'm on map, on trigger: two bots adding on server, spawning, getting wrench, stripping knife.
But knife won't strip, althrough bots have another weapon - wrench!
Can you help me?
edited 2×, last 26.06.12 12:14:27 pm

old Re: Script with "Second"

Alistaire
User Off Offline

Quote
user Kostyan1996 has written
Thanks man!
---
Need another help (sorry for my stupidness, I'm not good scripter yet)...

1
2
3
4
5
6
for i=2,3 do
			parse('bot_add_ct')
			parse('spawnplayer '..i..' 336 176')
			parse('equip '..i..' 74')
			parse('strip '..i..' 50')
		end

Must be: I'm on map, on trigger: two bots adding on server, spawning, getting wrench, stripping knife.
But knife won't strip, althrough bots have another weapon - wrench!
Can you help me?


You cant strip knifes from bots, and if you try it on players it's still pretty buggy.

old Re: Script with "Second"

Kostyan1996
User Off Offline

Quote
Ehh, thanks, try another.
---
Also, hooks "second", "minute" and other time hooks won't work normally. This:
1
2
3
4
5
addhook("minute","rand_dis")

function rand_dis()
	--code
end
Won't work... Maybe I need special string?..

old Re: Script with "Second"

Kostyan1996
User Off Offline

Quote
Hm. I can give you code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
---VARIABLES---

min_dis = 3

---~~~---

addhook("minute","rand_dis")

function rand_dis()
	dis = dis + 1
	if dis == min_dis then
		dis = 0
		rand_dis1 = 1
	end
end
This code means: every 3 mins value of variable "rand_dis1" becomes a "1" (in other site of code sometimes rand_dis1 becomes "0"). But rand_dis1 won't become "1". Also, if I delete
1
2
3
addhook("minute","rand_dis")

function rand_dis()
and
1
end
rand_dis1 becomes "1".

old Re: Script with "Second"

Alistaire
User Off Offline

Quote
have you declared dis anywhere else in the script, or are you just plunking nils on a huge error heap in that minute function.
To the start Previous 1 2 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview