Forum

> > CS2D > Scripts > Lua Scripts/Questions/Help
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Lua Scripts/Questions/Help

6.770 Antworten
Seite
Zum Anfang Vorherige 1 2284 285 286338 339 Nächste Zum Anfang

alt Re: Lua Scripts/Questions/Help

Twisted
User Off Offline

Zitieren
Is there a way to make it so if you walk over a certain spot with the flag, the flag gets returned and a entity gets triggered in the map maker?

alt Re: Lua Scripts/Questions/Help

saladface27
User Off Offline

Zitieren
right now my function is this:

1
2
3
4
5
6
7
8
9
function choosePlacer(team)
	local teamarray
	if(team==1)then
		teamarray=player(0,"team1")
	else
		teamarray=player(0,"team2")
		end
	return teamarray
end

is there anyway to make it more efficient?

@Banaan: thanks
1× editiert, zuletzt 20.10.10 11:35:30

alt Re: Lua Scripts/Questions/Help

Banaan
User Off Offline

Zitieren
saladface27 hat geschrieben
right now my function is this:

1
2
3
4
5
6
7
8
9
function choosePlacer(team)
	local teamarray
	if(team==1)then
		teamarray=player(0,"team1")
	else
		teamarray=player(0,"team2")
		end
	return teamarray
end

is there anyway to make it more efficient?


1
2
3
function choosePlacer(team)
	return player(0,"team"..team)
end

alt Re: Lua Scripts/Questions/Help

Triple H
User Off Offline

Zitieren
@CmDark: it's read like this is one file

1
ERROR: cannot play sound 'sfx/CoN_(FFA)(4FUN)/zxc2.CoN_(FFA)(4FUN)/ct20.wav' - file does not exist (sv_sound)

alt Re: Lua Scripts/Questions/Help

byengul
User Off Offline

Zitieren
byengul hat geschrieben
1
tilex, tiley = math.random(m.spawn1[1], m.spawn2[1], m.spawn3[1]), math.random(m.spawn1[2], m.spawn2[2], m.spawn3[2])

whats wrong?? please help me i want to make 3 spawn point


help please i need this to my tibia rpg 3 monster spawn point

alt Re: Lua Scripts/Questions/Help

FASTDIE
User Off Offline

Zitieren
saladface27 hat geschrieben
what player value could i use to test whether a player is alive

eg if(player(id,"alive")==1)then...


use this:
1
if player(id,"exists") then....
read info.txt in your lua dir

alt Re: Lua Scripts/Questions/Help

TDShuft
User Off Offline

Zitieren
FaStDiE hat geschrieben
saladface27 hat geschrieben
what player value could i use to test whether a player is alive

eg if(player(id,"alive")==1)then...


use this:
1
if player(id,"exists") then....
read info.txt in your lua dir

he means alive not if the id exists,
its "if player(id,"health") >= 1 then"

edit: ... its wrong again the ps
is not >= 0 ,
thats if died or alive
he wants just alive so its
>= 1
or
> 0
2× editiert, zuletzt 20.10.10 17:54:21

alt Re: Lua Scripts/Questions/Help

FASTDIE
User Off Offline

Zitieren
TDShuft hat geschrieben
FaStDiE hat geschrieben
saladface27 hat geschrieben
what player value could i use to test whether a player is alive

eg if(player(id,"alive")==1)then...


use this:
1
if player(id,"exists") then....
read info.txt in your lua dir

he means alive not if the id exists,
its "if player(id,"health") >= 1 then"

ohh.. i didn see older posts
p.s. >= 0

alt Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Zitieren
byengul hat geschrieben
1
tilex, tiley = math.random(m.spawn1[1], m.spawn2[1], m.spawn3[1]), math.random(m.spawn1[2], m.spawn2[2], m.spawn3[2])


math.random has the following signature:

1
math.random(number) -- Note: At most 1 parameter.

Also, since the spawn points' components aren't interchangeable, you cannot randomize the order of both x and y. For example, if you have the following points:

sp1 = {1,2}
sp2 = {3,4}

Your spawn points are {1,2} and {3,4}, not {1,2}, {1,3}, {2,3}, and {2,4}

Hence:
1
2
local sp = "spawn"+tostring(math.random(3))
tilex, tiley = m[sp][1], m[sp][2]

@FastSide: A dead player also exists xP
Check to see whether a player's health is greater than 0: player(id, "health") > 0

Zitat
Hi guys!
Is there any math.function which returns the radians of a player like 1-259?


Try math.rad(degree) and math.deg(radians), they are also easily implementable using trivial arithmetic.

@Triple H:
You can't concatenate the files, write them out as two parses.

alt Re: Lua Scripts/Questions/Help

Tajifun
User Off Offline

Zitieren
@FaStDiE

FaStDiE hat geschrieben
ohh.. i didn see older posts
p.s. >= 0


why >= 0 ?
It would include dead players, too.

>= 1 will work.

alt Re: Lua Scripts/Questions/Help

HaRe
User Off Offline

Zitieren
FaStDiE hat geschrieben
>= 1 will work but wont work for player with 1 hp
ps: he edited this


YEs it will lol

> means above the number wich he've choosed 1

= means the number wich he've choosed 1

so

>= means the number and above the number

stop discussing about this

alt Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Zitieren
TDShuft hat geschrieben
can i make like if the player is stoped in hook second he gets +1 mp and if he walking he gets nothing


Yes and no. You will need to find the average velocity of the player and make sure that it's zero. This can be done quite easily:

1
2
3
4
5
6
7
8
9
10
11
12
13
pos = {}
addhook("second", "check_players_pos")
function check_players_pos()
	for _,id in player(0, "table") do
		if not pos[id] then pos[id] = {0,0} end
		local dx, dy = player(id,"x")-pos[id][0], player(id, "y")-pos[id][1]
		if dx == 0 and dy == 0 then 
			local health = "sethealth %s %s"
			parse(health:format(id, player(id, "health")+1))
		end
		pos[id][0], pos[id][1] = pos[id][0] + dx, pos[id][1] + dy
	end
end

alt Re: Lua Scripts/Questions/Help

Chex
User Off Offline

Zitieren
I can't make a random weapon generator!
All my comp does is close cs2d when I try to use it.
Here:



parse("sv_name battlefield")
parse("mp_infammo 1")
parse("mp_randomspawn 1")
parse("sv_gamemode 1")

--weapon randomization
addhook("spawn","maps.battlefield.weapon")
function maps.battlefield.weapon()
     if (player(i,"exists")) then
     equip(player,math.random)
     end
end

alt Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Zitieren
Arcas hat geschrieben
1
2
3
4
5
6
addhook("spawn","maps.battlefield.weapon")
function maps.battlefield.weapon()
	if (player(i,"exists")) then
	equip(player,math.random)
	end
end


1
2
3
4
5
math.randomseed(os.time())
addhook("spawn","battlefield_weapon")
function battlefield_weapon(id)
	parse(string.format("equip %s %s",id,math.random(10,49)))
end
Zum Anfang Vorherige 1 2284 285 286338 339 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht