Forum

> > CS2D > Scripts > Base will spawn in Flare pos
Forums overviewCS2D overview Scripts overviewLog in to reply

English Base will spawn in Flare pos

6 replies
To the start Previous 1 Next To the start

old Base will spawn in Flare pos

DX
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
addhook("projectile","a")
function a(id,wpn,x,y)
	if (wpn == 54) then
		local team = player(id,"team")
			x = player(id,"tilex")   
			y = player(id,"tiley")
					parse ("spawnobject 11 "..(x-2).." "..(y-2).." 0 0 "..team.." "..id)
					parse ("spawnobject 1 "..(x-1).." "..(y-2).." 0 0 "..team.." "..id)
					parse ("spawnobject 1 "..(x).." "..(y-2).." 0 0 "..team.." "..id)
					parse ("spawnobject 1 "..(x+1).." "..(y-2).." 0 0 "..team.." "..id)
					parse ("spawnobject 11 "..(x+2).." "..(y-2).." 0 0 "..team.." "..id)
					parse ("spawnobject 1 "..(x+2).." "..(y-1).." 0 0 "..team.." "..id)
					parse ("spawnobject 1 "..(x+2).." "..(y).." 0 0 "..team.." "..id)
					parse ("spawnobject 1 "..(x+2).." "..(y+1).." 0 0 "..team.." "..id)
					parse ("spawnobject 11 "..(x+2).." "..(y+2).." 0 0 "..team.." "..id)
					parse ("spawnobject 1 "..(x+1).." "..(y+2).." 0 0 "..team.." "..id)
					parse ("spawnobject 1 "..(x).." "..(y+2).." 0 0 "..team.." "..id)
					parse ("spawnobject 1 "..(x-1).." "..(y+2).." 0 0 "..team.." "..id)
					parse ("spawnobject 11 "..(x-2).." "..(y+2).." 0 0 "..team.." "..id)
					parse ("spawnobject 1 "..(x-2).." "..(y+1).." 0 0 "..team.." "..id)
					parse ("spawnobject 1 "..(x-2).." "..(y).." 0 0 "..team.." "..id)
					parse ("spawnobject 1 "..(x-2).." "..(y-1).." 0 0 "..team.." "..id)
				parse ("spawnobject 6 "..(x-1).." "..(y-1).." 0 0 "..team.." "..id)
				parse ("spawnobject 6 "..(x).." "..(y-1).." 0 0 "..team.." "..id)
				parse ("spawnobject 6 "..(x+1).." "..(y-1).." 0 0 "..team.." "..id)
				parse ("spawnobject 6 "..(x+1).." "..(y).." 0 0 "..team.." "..id)
				parse ("spawnobject 6 "..(x+1).." "..(y+1).." 0 0 "..team.." "..id)
				parse ("spawnobject 6 "..(x).." "..(y+1).." 0 0 "..team.." "..id)
				parse ("spawnobject 6 "..(x-1).." "..(y+1).." 0 0 "..team.." "..id)
				parse ("spawnobject 6 "..(x-1).." "..(y).." 0 0 "..team.." "..id)
		end			
	end

When I throw the flare the base will appear not on my player position

if the first one is too long you can give me an example with this one

1
2
3
4
5
6
7
8
9
10
11
addhook("projectile","a")
function a(id,wpn,x,y)
	if (wpn == 54) then
		local team = player(id,"team")
				parse ("spawnobject 11 "..((x-16)/32).." "..((y-16)/32).." 0 0 "..team.." "..id)
				parse ("spawnobject 11 "..((x-16)/31).." "..((y-16)/33).." 0 0 "..team.." "..id)
				parse ("spawnobject 11 "..((x-16)/33).." "..((y-16)/31).." 0 0 "..team.." "..id)
				parse ("spawnobject 11 "..((x-16)/30).." "..((y-16)/34).." 0 0 "..team.." "..id)
				parse ("spawnobject 11 "..((x-16)/34).." "..((y-16)/30).." 0 0 "..team.." "..id)
		end
	end
edited 3×, last 18.11.20 01:06:49 pm

old Re: Base will spawn in Flare pos

Cebra
User Off Offline

Quote
@user DX: i would suggest that you ask/express a question, if you have one. Of course, we know what are you asking for, but this would show, that you have thought about your request and you know what are you doing. You would also show a minimum of respect.
And it is simply polite. (btw i think user The Dark Shadow is right)

ps: maybe you start to learn lua scripting (here?)

old Done

VADemon
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
addhook("attack", "vFlareBase.attack")
vFlareBase = {}

function vFlareBase.attack(id) --on throwing
	if player(id, "weapontype")==52 or player(id, "weapontype")==0 then
		vFlareBase.check_for_flare(id)
	end
end

function vFlareBase.check_for_flare(PLAYERID)
	local list = projectilelist(0,tonumber(PLAYERID)) --flying projectiles

	for k,p in pairs(list) do
		if projectile(p.id, PLAYERID, "type")==54 then
			print(p.id, PLAYERID)
			timer(1000, "vFlareBase.flareLanded", p.id.."\n"..PLAYERID)
			--msg("New flare detected")
		end
	end
end

function vFlareBase.flareLanded(timerNameArg)
	local projID, playerID = string.match(timerNameArg, "(%d+)\n(%d+)")
	local projID, playerID = tonumber(projID), tonumber(playerID)
	
	
	local pX, pY = projectile(projID, playerID, "x"), projectile(projID, playerID, "y")
	local pTileX, pTileY = math.floor(pX / 32), math.floor(pY / 32)
	
	vFlareBase.buildBase(pTileX, pTileY, playerID)
	
	parse("freeprojectile "..timerNameArg)
end

function vFlareBase.buildBase(x, y, playerID)
	local id = playerID
	local team = player(playerID, "team")
	
	parse ("spawnobject 11 "..(x-2).." "..(y-2).." 0 0 "..team.." "..id)
	parse ("spawnobject 1 "..(x-1).." "..(y-2).." 0 0 "..team.." "..id)
	parse ("spawnobject 1 "..(x).." "..(y-2).." 0 0 "..team.." "..id)
	parse ("spawnobject 1 "..(x+1).." "..(y-2).." 0 0 "..team.." "..id)
	parse ("spawnobject 11 "..(x+2).." "..(y-2).." 0 0 "..team.." "..id)
	parse ("spawnobject 1 "..(x+2).." "..(y-1).." 0 0 "..team.." "..id)
	parse ("spawnobject 1 "..(x+2).." "..(y).." 0 0 "..team.." "..id)
	parse ("spawnobject 1 "..(x+2).." "..(y+1).." 0 0 "..team.." "..id)
	parse ("spawnobject 11 "..(x+2).." "..(y+2).." 0 0 "..team.." "..id)
	parse ("spawnobject 1 "..(x+1).." "..(y+2).." 0 0 "..team.." "..id)
	parse ("spawnobject 1 "..(x).." "..(y+2).." 0 0 "..team.." "..id)
	parse ("spawnobject 1 "..(x-1).." "..(y+2).." 0 0 "..team.." "..id)
	parse ("spawnobject 11 "..(x-2).." "..(y+2).." 0 0 "..team.." "..id)
	parse ("spawnobject 1 "..(x-2).." "..(y+1).." 0 0 "..team.." "..id)
	parse ("spawnobject 1 "..(x-2).." "..(y).." 0 0 "..team.." "..id)
	parse ("spawnobject 1 "..(x-2).." "..(y-1).." 0 0 "..team.." "..id)
	
	for xOffset = -1, 1, 1 do -- for each x (-1,0,1)
		for yOffset = -1, 1, 1 do -- for each y (-1,0,1)
			print(xOffset ..",".. yOffset)
			if not (xOffset == 0 and yOffset == 0) then
				parse("spawnobject 6 "..(x+xOffset).." "..(y+yOffset).." 0 0 "..team.." "..id)
			end
		end
	end
	--[[ refactored into for-loop above
	parse ("spawnobject 6 "..(x-1).." "..(y-1).." 0 0 "..team.." "..id)
	parse ("spawnobject 6 "..(x).." "..(y-1).." 0 0 "..team.." "..id)
	parse ("spawnobject 6 "..(x+1).." "..(y-1).." 0 0 "..team.." "..id)
	parse ("spawnobject 6 "..(x+1).." "..(y).." 0 0 "..team.." "..id)
	parse ("spawnobject 6 "..(x+1).." "..(y+1).." 0 0 "..team.." "..id)
	parse ("spawnobject 6 "..(x).." "..(y+1).." 0 0 "..team.." "..id)
	parse ("spawnobject 6 "..(x-1).." "..(y+1).." 0 0 "..team.." "..id)
	parse ("spawnobject 6 "..(x-1).." "..(y).." 0 0 "..team.." "..id)
	]]
end

Based on my old anti-teamflash code. That code was removed from uploads here because a certain -iq user by the name of user sheeL thought I stole his code (lie) and complained to user DC who then removed my original (and better) code without looking into it.

@user DX: You should be able to easily adapt/change the code above.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview