Forum

> > CS2D > Scripts > my map script doesn't work
Forums overviewCS2D overview Scripts overviewLog in to reply

English my map script doesn't work

5 replies
To the start Previous 1 Next To the start

old my map script doesn't work

zazz
User Off Offline

Quote
Hey usS, sorry for bothering again.
When i try to run a weapon detector script in my map, it doesn't work. it has the same name as my map, and it's in maps folder aswell.

Soushi made this script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
--Scanner location, input in tile format!
tilex = 119
tiley = 137
--Enter your mapname here
mapName = 'zAzz_Jail'

addhook("movetile","movetile_hook")
function movetile_hook(id ,playerx ,playery)
     if map("name") == mapName then
          if tilex == playerx and tiley == playery then
               local weapons = playerweapons(id)
               if #weapons > 1 then
                    parse('trigger "hasWeapons"')
               else
                    parse('trigger "hasNoWeapons"')
               end
          end
     end
end

It doesn't trigger the sound when i step in the tile.
All this kind of scripts aren't working in my map
What the hell is the problem?

Luamap is enabled
Other maps have the same scripts and they work.
But no one seems to work in my map..

old Re: my map script doesn't work

Cure Pikachu
User Off Offline

Quote
• Does the map have any sound entities named "hasWeapons" and "hasNoWeapons" (case sensitive)?
• Does the said entities are configured properly and have audible sound?
More >

old Re: my map script doesn't work

Cure Pikachu
User Off Offline

Quote
@user zazz: The code I just provided won't work, duh, I am just making a point there.

Removing the redundant part leaves us with this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
--Scanner location, input in tile format!
tilex = 119
tiley = 137

addhook("movetile","movetile_hook")
function movetile_hook(id,playerx,playery)
	if playerx == tilex and playery == tiley then
		local weapons = playerweapons(id)
		if #weapons > 1 then
			parse('trigger "hasWeapons"')
		else
			parse('trigger "hasNoWeapons"')
		end
	end
end

old Re: my map script doesn't work

Rainoth
Moderator Off Offline

Quote
@user zazz: Just debug it then. You'll see where the script goes stuck and if it isn't stuck anywhere, it's the fault of map/user/entities.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
print("ding")
--Scanner location, input in tile format!
tilex = 119
tiley = 137

addhook("movetile","movetile_hook")
function movetile_hook(id,playerx,playery)
print("dong")
     if playerx == tilex and playery == tiley then
	print("tic")
          local weapons = playerweapons(id)
          if #weapons > 1 then
		print("tac")
               parse('trigger "hasWeapons"')
          else
               parse('trigger "hasNoWeapons"')
		print("toe")
          end
     end
end

Ding :3

// If anyone wonders why it wasn't working, he was using wrong encoding. Now everything works.
edited 1×, last 29.11.15 05:04:30 pm
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview