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 2324 325 326338 339 Nächste Zum Anfang

alt Re: Lua Scripts/Questions/Help

Yasday
User Off Offline

Zitieren
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?

alt Re: Lua Scripts/Questions/Help

JONY
User Off Offline

Zitieren
Yasday hat geschrieben
just try... i cant do anythin now cuz... i gotta sleep some time
and why 12?


12 - tripple Turret

alt Re: Lua Scripts/Questions/Help

J4x
User Off Offline

Zitieren
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
3× editiert, zuletzt 11.12.10 02:22:41

alt Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Zitieren
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

alt Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Zitieren
CmDark hat geschrieben
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...

alt Re: Lua Scripts/Questions/Help

wjcf1290
User Off Offline

Zitieren
JONY hat geschrieben
Yasday hat geschrieben
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)
]]

alt Re: Lua Scripts/Questions/Help

Fehu
User Off Offline

Zitieren
Danikah hat geschrieben
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...

alt Re: Lua Scripts/Questions/Help

SkullFace
User Off Offline

Zitieren
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)
1× editiert, zuletzt 11.12.10 14:37:00

alt Re: Lua Scripts/Questions/Help

JONY
User Off Offline

Zitieren
wjcf1290 hat geschrieben
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 ?

alt Re: Lua Scripts/Questions/Help

Fehu
User Off Offline

Zitieren
wjcf1290 hat geschrieben
Fehuziom hat geschrieben
How to create big menu ?


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


Thanks! cookie

alt Re: Lua Scripts/Questions/Help

BetaM
User Off Offline

Zitieren
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.

alt Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Zitieren
Mat5b, tangent functions makes this easier.
You should take a look at these functions.
1
2
math.atan(y/x)
math.atan2(y,x)
1× editiert, zuletzt 11.12.10 19:45:40

alt Re: Lua Scripts/Questions/Help

Loooser
User Off Offline

Zitieren
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)

alt Re: Lua Scripts/Questions/Help

Kurumi
User Off Offline

Zitieren
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

alt Re: Lua Scripts/Questions/Help

JONY
User Off Offline

Zitieren
FN_Nemesis hat geschrieben
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 hat geschrieben
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
1× editiert, zuletzt 11.12.10 21:22:41
Zum Anfang Vorherige 1 2324 325 326338 339 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht