Forum

> > CS2D > Scripts > Lua Scripts/Questions/Help
Forums overviewCS2D overview Scripts overviewLog in to reply

English Lua Scripts/Questions/Help

6,770 replies
Page
To the start Previous 1 2324 325 326338 339 Next To the start

old Re: Lua Scripts/Questions/Help

Yasday
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
addhook("second","turret")
function turret()
     if (object(12,"exists") and object(12,"target") ~= 0 and object(12,"target") ~= object(12,"player")) then
     local id = object(12,"target")
          if (player(id,"health"))>=11 then
               parse("sethealth "..id.." "..player(id,"health")-10)
          else
               parse("customkill "..id.." Turret "..id)
          end
     end
end
just try... i cant do anythin now cuz... i gotta sleep some time
and why 12?

old Re: Lua Scripts/Questions/Help

JONY
User Off Offline

Quote
Yasday has written
just try... i cant do anythin now cuz... i gotta sleep some time
and why 12?


12 - tripple Turret

old Re: Lua Scripts/Questions/Help

J4x
User Off Offline

Quote
I think that i resolve the boolean thing but no so, can someone help me? it sends me an error but the script works
fine
it says me : Atemp to compare number with boolean
1
2
3
4
5
6
7
8
addhook("second","live")
function live(i,hpdmg)
for i =1,32 do
if (player (i,"health"))>= 99 then
parse("sethealth "..i.." "..player(i,"health")+5)
end
end
end
edited 3×, last 11.12.10 02:22:41 am

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
addhook("second","live")
function live(i,hpdmg)
	for i =1,32 do
		if player(i,"exists") then
			if (player (i,"health"))>= 99 then
				parse("sethealth "..i.." "..player(i,"health")+5)
			end
		end
	end
end

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
CmDark has written
Why'd you put parameters into the second hook?

Because I obviously didn't read the code.
Now I can also see that the player will regenerate hp only when he's got 99 health or more.
Whatever...

old Re: Lua Scripts/Questions/Help

wjcf1290
User Off Offline

Quote
JONY has written
Yasday has written
just try... i cant do anythin now cuz... i gotta sleep some time
and why 12?


12 - tripple Turret


really?

1
2
3
4
5
6
7
8
9
10
11
12
--[[
if the map only one Tripple Turret.
]]

print(object(1,"type"))  --12
print(object(1,"typename")) --Tripple Turret
-- object(1,"exists") --true

--[[
so,
object_type_id ~= object_id (12 ~= 1)
]]

old Re: Lua Scripts/Questions/Help

Fehu
User Off Offline

Quote
Danikah has written
Is it possible to change a weapon's damage for only ONE player? I thought about:
1. change it to the specific amount, then
2. do the attack, then
3. change back. But I think that will be buggy.
So can somebody help me?


This is possible use initArray func and hit hook good luck...

old Re: Lua Scripts/Questions/Help

Casper-
User Off Offline

Quote
Help please.

Is it possible for multiple "ai_goto" ?

Like every single bot goes to single "ai_goto".

P.S. Can somebody explain me how to use "ai_goto" ? (Not necessary)
edited 1×, last 11.12.10 02:37:00 pm

old Re: Lua Scripts/Questions/Help

JONY
User Off Offline

Quote
wjcf1290 has written
1
2
3
4
5
6
7
8
9
10
11
12
--[[
if the map only one Tripple Turret.
]]

print(object(1,"type"))  --12
print(object(1,"typename")) --Tripple Turret
-- object(1,"exists") --true

--[[
so,
object_type_id ~= object_id (12 ~= 1)
]]


thanx, bro
so in object(id, "type") id stands for the number of buildings "type" on the map ?

old Re: Lua Scripts/Questions/Help

Fehu
User Off Offline

Quote
wjcf1290 has written
Fehuziom has written
How to create big menu ?


menu(id,"<menu name>@b,<b1>,<b2>,.....,<b9>")


Thanks! cookie

old Re: Lua Scripts/Questions/Help

BetaM
User Off Offline

Quote
I have a minor mathematical question concerning calculating an angle. Take a look at this poorly drawn Paint image:

IMG:https://dl.dropbox.com/u/12151154/skitz.png


( X is always a vertical line, Y is any line)
Basically, I am in need of a formula for calculating these angles. I showed this to my talented friend and he said that this would require knowledge about trigonometric functions (which I currently don't understand, and the mathematical level at my school isn't high enough to let people learn such stuff at my class).

If you know it, then please explain in layman's terms what values does it need and possibly work out a formula for that. Of course you'll get credit in my future project(s) if you can do that.

old Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Quote
Mat5b, tangent functions makes this easier.
You should take a look at these functions.
1
2
math.atan(y/x)
math.atan2(y,x)
edited 1×, last 11.12.10 07:45:40 pm

old Re: Lua Scripts/Questions/Help

Loooser
User Off Offline

Quote
can someone help me?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
function fai_getbuilding(team,type)
local b =object(0,"table")
if #b~=0 then
local l = 0
local i = 0
while i<=#b and l==0 do
i=i+1
local oteam = object(b[i],"team")  			--this is line 194
if oteam==team and object(b[i],"type")==7 then
l=1
return b[i]
end
end
if i>#b and l==0 then
return 0
end
else
return 0
end
end

this is the error

LUA ERROR (ai_update_living): bots/includes/general.lua:194: bad argument #1 to 'object' (number expected, got nil)

old Re: Lua Scripts/Questions/Help

Kurumi
User Off Offline

Quote
Plz give me script that triggers snd EVERY 50sec's (triger_delay doesnt help) and shows msg "Round 1 ,2 ,3..." changes the numbers every time, bcs it'll be really many func_msgs in the map and many work too

old Re: Lua Scripts/Questions/Help

JONY
User Off Offline

Quote
FN_Nemesis has written
Can someone explain me what is a boolean?
i read in wikipedia that is a logic data type and is used to represent true or false, but i dont know what is its function in lua... http://en.wikipedia.org/wiki/Boolean_data_type


Boolean is a primitive data type, like Integer, String, etc... It gives you a value of true or false, for example:
1
2
3
if (1<2) then
	some code...
end

you obviously understand that 1 is always smaller then 2 that means that (1<2) is always TRUE

In cs2d case, you can put it like this:
1
2
3
if player(id,"exists") then
	some code...
end

So it checks if the player exists, if he does exist then the statement player(id,"exists") is TRUE, if the player is not found then it's FALSE and this if-statement will not be executed. I hope this gives you some kind of idea of what a boolean is.

GeNeSiS_MaSoN has written
Plz give me script that triggers snd EVERY 50sec's (triger_delay doesnt help) and shows msg "Round 1 ,2 ,3..." changes the numbers every time, bcs it'll be really many func_msgs in the map and many work too


Try this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
local a = 1
timer(50000,"call",0)
function call()
	trigger("names_of_entities_you_want_to_trigger")
end

addhook("startround","display")
function display()
	parse("sv_msg Round "..a.."@C")
end

addhook("endround","increment")
function increment()
	a=a+1
end

And read about functions:
message
trigger

And for timer read info.txt
edited 1×, last 11.12.10 09:22:41 pm
To the start Previous 1 2324 325 326338 339 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview