Forum
CS2D Scripts Lua Scripts/Questions/Help1
2
3
4
5
6
7
8
9
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
edited 1×, last 20.10.10 11:35:30 am
saladface27 has written
right now my function is this:
is there anyway to make it more efficient?
1
2
3
4
5
6
7
8
9
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
2
3
function choosePlacer(team) 	return player(0,"team"..team) end
Is there any math.function which returns the radians of a player like 1-259?
help pls
eg if(player(id,"alive")==1)then...
1
ERROR: cannot play sound 'sfx/CoN_(FFA)(4FUN)/zxc2.CoN_(FFA)(4FUN)/ct20.wav' - file does not exist (sv_sound)
byengul has written
whats wrong?? please help me i want to make 3 spawn point
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
saladface27 has written
what player value could i use to test whether a player is alive
eg if(player(id,"alive")==1)then...
eg if(player(id,"alive")==1)then...
use this:
1
if player(id,"exists") then....
FaStDiE has written
use this:
read info.txt in your lua dir
saladface27 has written
what player value could i use to test whether a player is alive
eg if(player(id,"alive")==1)then...
eg if(player(id,"alive")==1)then...
use this:
1
if player(id,"exists") then....
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
edited 2×, last 20.10.10 05:54:21 pm
TDShuft has written
he means alive not if the id exists,
its "if player(id,"health") >= 1 then"
FaStDiE has written
use this:
read info.txt in your lua dir
saladface27 has written
what player value could i use to test whether a player is alive
eg if(player(id,"alive")==1)then...
eg if(player(id,"alive")==1)then...
use this:
1
if player(id,"exists") then....
he means alive not if the id exists,
its "if player(id,"health") >= 1 then"
ohh.. i didn see older posts
p.s. >= 0
byengul has written
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
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
Quote
Hi guys!
Is there any math.function which returns the radians of a player like 1-259?
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.
FaStDiE has written
ohh.. i didn see older posts
p.s. >= 0
p.s. >= 0
why >= 0 ?
It would include dead players, too.
>= 1 will work.
ps: he edited this
FaStDiE has written
>= 1 will work but wont work for player with 1 hp
ps: he edited this
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
TDShuft has written
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
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
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
Arcas has written
1
2
3
4
5
6
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
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