English Lua Scripts/Questions/Help

6,770 replies
Goto Page
To the start Previous 1 2 ... 284 285 286 ... 338 339 Next To the start
20.10.10 10:01:47 am
Up
Twisted
User
Offline Off
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?
20.10.10 11:09:29 am
Up
saladface27
User
Offline Off
right now my function is this:

Code:
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
edited 1×, last 20.10.10 11:35:30 am
20.10.10 11:31:38 am
Up
Banaan
User
Offline Off
saladface27 has written:
right now my function is this:

Code:
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?


Code:
1
2
3
function choosePlacer(team)
     return player(0,"team"..team)
end
20.10.10 02:15:50 pm
Up
Snake_Eater
User
Offline Off
Hi guys!     
Is there any math.function which returns the radians of a player like 1-259?

help pls
[Death Note]
20.10.10 03:02:56 pm
Up
saladface27
User
Offline Off
what player value could i use to test whether a player is alive

eg if(player(id,"alive")==1)then...
20.10.10 03:35:11 pm
Up
Triple H
User
Offline Off
@CmDark: it's read like this is one file

Code:
1
ERROR: cannot play sound 'sfx/CoN_(FFA)(4FUN)/zxc2.CoN_(FFA)(4FUN)/ct20.wav' - file does not exist (sv_sound)
20.10.10 03:59:28 pm
Up
byengul
User
Offline Off
byengul has written:
Code:
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
After 2 years i'm back to cs2d. cookie for everyone
20.10.10 05:40:38 pm
Up
FASTDIE
User
Offline Off
saladface27 has written:
what player value could i use to test whether a player is alive

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


use this:
Code:
1
if player(id,"exists") then....

read info.txt in your lua dir
20.10.10 05:49:11 pm
Up
TDShuft
User
Offline Off
FaStDiE has written:
saladface27 has written:
what player value could i use to test whether a player is alive

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


use this:
Code:
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
edited 2×, last 20.10.10 05:54:21 pm
Sorry , I can't be Perfect !
20.10.10 05:52:27 pm
Up
FASTDIE
User
Offline Off
TDShuft has written:
FaStDiE has written:
saladface27 has written:
what player value could i use to test whether a player is alive

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


use this:
Code:
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
20.10.10 05:55:06 pm
Up
Lee
Moderator
Offline Off
byengul has written:
Code:
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:

Code:
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:
Code:
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

Quote:
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.
20.10.10 07:17:01 pm
Up
Tajifun
User
Offline Off
@FaStDiE

FaStDiE has written:
ohh.. i didn see older posts
p.s. >= 0


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

>= 1 will work.
Tajifun yay.
20.10.10 07:22:24 pm
Up
byengul
User
Offline Off
@lee thx
After 2 years i'm back to cs2d. cookie for everyone
20.10.10 07:22:52 pm
Up
FASTDIE
User
Offline Off
>= 1 will work but wont work for player with 1 hp
ps: he edited this
20.10.10 07:47:14 pm
Up
HaRe
User
Offline Off
FaStDiE has written:
>= 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
w0w im so eXotiK
20.10.10 08:49:38 pm
Up
TDShuft
User
Offline Off
can i make like if the player is stoped in hook second he gets +1 mp and if he walking he gets nothing
Sorry , I can't be Perfect !
20.10.10 09:04:41 pm
Up
Lee
Moderator
Offline Off
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:

Code:
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
20.10.10 09:07:30 pm
Up
Chex
User
Offline Off
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
Who needs a sig?
20.10.10 09:15:04 pm
Up
Lee
Moderator
Offline Off
Arcas has written:
Code:
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


Code:
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
20.10.10 09:19:07 pm
Up
Chex
User
Offline Off
Thanks, I just started lua so I'm not very good at it.
Who needs a sig?
To the start Previous 1 2 ... 284 285 286 ... 338 339 Next To the start