English Lua Scripts/Questions/Help

6,770 replies
Goto Page
To the start Previous 1 2 ... 324 325 326 ... 338 339 Next To the start
11.12.10 12:18:02 am
Up
Yasday
User
Offline Off
Code:
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?
11.12.10 12:46:54 am
Up
JONY
User
Offline Off
Yasday has written:
just try... i cant do anythin now cuz... i gotta sleep some time
and why 12?


12 - tripple Turret
11.12.10 01:38:44 am
Up
J4x
User
Offline Off
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
Code:
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
11.12.10 07:08:15 am
Up
Flacko
User
Offline Off
Code:
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
11.12.10 07:48:23 am
Up
CmDark
User
Offline Off
Why'd you put parameters into the second hook?
IMG:http://i54.tinypic.com/auk478.png
11.12.10 08:44:25 am
Up
Flacko
User
Offline Off
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...
11.12.10 09:01:12 am
Up
wjcf1290
User
Offline Off
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?

Code:
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)
]]
11.12.10 10:48:20 am
Up
Fehu
User
Offline Off
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...
IMG:http://www.flashflashrevolution.com/profile/newsiggy/Fehu/stardust/0/0-1-2-3-4-5.png
11.12.10 01:26:20 pm
Up
SkullFace
User
Offline Off
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
IMG:https://i.imgur.com/kZBVkjM.gif
P.S. - I've been extracting recently enviromental sound files from other games, if anyone is interested in them for adding them to their maps, scripts, PM me
11.12.10 04:22:32 pm
Up
Fehu
User
Offline Off
How to create big menu ?
IMG:http://www.flashflashrevolution.com/profile/newsiggy/Fehu/stardust/0/0-1-2-3-4-5.png
11.12.10 04:38:32 pm
Up
JONY
User
Offline Off
wjcf1290 has written:
Code:
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 ?
11.12.10 04:40:38 pm
Up
wjcf1290
User
Offline Off
Fehuziom has written:
How to create big menu ?


menu(id,"<menu name>@b,<b1>,<b2>,.....,<b9>")
11.12.10 04:52:58 pm
Up
Fehu
User
Offline Off
wjcf1290 has written:
Fehuziom has written:
How to create big menu ?


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


Thanks! cookie
IMG:http://www.flashflashrevolution.com/profile/newsiggy/Fehu/stardust/0/0-1-2-3-4-5.png
11.12.10 05:58:05 pm
Up
BetaM
User
Offline Off
I have a minor mathematical question concerning calculating an angle. Take a look at this poorly drawn Paint image:

IMG:http://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.
11.12.10 06:38:22 pm
Up
J4x
User
Offline Off
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
11.12.10 07:30:21 pm
Up
SQ
Moderator
Offline Off
Mat5b, tangent functions makes this easier.
You should take a look at these functions.
Code:
1
2
math.atan(y/x)
math.atan2(y,x)
edited 1×, last 11.12.10 07:45:40 pm
11.12.10 07:39:34 pm
Up
Loooser
User
Offline Off
can someone help me?
Code:
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)
IMG:http://i45.tinypic.com/saus1e.jpg
11.12.10 08:45:22 pm
Up
Kurumi
User
Offline Off
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
Uhm... Hello
11.12.10 09:05:27 pm
Up
JONY
User
Offline Off
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:
Code:
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:
Code:
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:
Code:
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
11.12.10 11:08:29 pm
Up
J4x
User
Offline Off
thx for the info. jony
To the start Previous 1 2 ... 324 325 326 ... 338 339 Next To the start