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 2312 313 314338 339 Next To the start

old Re: Lua Scripts/Questions/Help

Yasday
User Off Offline

Quote
i think he thought this :

1
2
3
4
5
6
addhook("projectile","ThrowSnow")
function ThrowSnow(id,weapon,x,y)
     if weapon == 75 then
          parse("spawnitem 75 "..x.." "..y)
     end
end

@Anders4000 sry but i don't mean ur a noob.
i didn't know you can programm this good
i already tried vb c++ actionscript 3+2 php phyton and css, but i think lua FOR CS2D is best because i really like cs2d

but lua is easy too, and i tried to do some things with it
lua is a great script language, i saw many games that have lua script, and i like them too

edit//@Flacko fail, i copied the code from anders because im on ipod lol
edited 2×, last 18.11.10 11:54:02 pm

old Re: Lua Scripts/Questions/Help

TWBiBi
User Off Offline

Quote
Admir has written
@TWBiBi

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
addhook ("say","maketeam")
function maketeam(p,txt)
   if (txt=="@maket") then
   parse("maket "..p)
   msg("©032178170 "..player(p,"name").." used @maket") 
   
   elseif (txt=="@makect") then
    parse("makect "..p)
	msg("©032178170  "..player(p,"name").." used @makect") 
	 
   elseif (txt=="@makespec") then
    parse("makespec "..p)
    msg("©032178170 "..player(p,"name").." used @maket") 
    return 1
   end
 end

thank you admir !!
but I have a question why parse(maket" ..p). what is p meaning? can I use parse("maket" ..id)
btw...
UM... It's work??
1
msg("©032178170 "..player(p,"name").." used @maket"..victim..)
if admir is victim.
ex: Bi Bi used @makect Admir

old Re: Lua Scripts/Questions/Help

Admir
User Off Offline

Quote
TWBiBi has written
but I have a question why parse(maket" ..p). what is p meaning? can I use parse("maket" ..id)
btw...
UM... It's work??
1
msg("©032178170 "..player(p,"name").." used @maket"..victim..)
if admir is victim.
ex: Bi Bi used @makect Admir


see your function,
1
function maketeam(p,txt)
there is a "p" there, which is for player ID's but you can change name ofc.

EDIT: I think that code you need Lee totable string I guess =\

old Re: Lua Scripts/Questions/Help

Anders4000
User Off Offline

Quote
Yasday has written
i think he thought this :

1
2
3
4
5
6
addhook("projectile","ThrowSnow")
function ThrowSnow(id,weapon,x,y)
     if weapon == 75 then
          parse("spawnitem 75 "..x.." "..y)
     end
end

@Anders4000 sry but i don't mean ur a noob.
i didn't know you can programm this good
i already tried vb c++ actionscript 3+2 php phyton and css, but i think lua FOR CS2D is best because i really like cs2d

but lua is easy too, and i tried to do some things with it
lua is a great script language, i saw many games that have lua script, and i like them too

edit//@Flacko fail, i copied the code from anders because im on ipod lol


I might have missunderstood him then (: Lets see his reply.

old KNOCKBACK

Jake-rus
User Off Offline

Quote
I need a working knockback script like this :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
addhook("hit","hits")
function hits(id,source)
if player(id,"team")==1 and player(id,"team")~=player(source,"team") then
if player(source,"y")-16>player(id,"y") then
parse("setpos "..id.." "..player(id,"x").." "..-zm_knock[id]+player(id,"y"))
elseif player(source,"y")+16<player(id,"y") then
parse("setpos "..id.." "..player(id,"x").." "..zm_knock[id]+player(id,"y"))
end
if player(source,"x")-16>player(id,"x") then
parse("setpos "..id.." "..-zm_knock[id]+player(id,"x").." "..player(id,"y"))
elseif player(source,"x")+16<player(id,"x") then
parse("setpos "..id.." "..zm_knock[id]+player(id,"x").." "..player(id,"y"))
end
end
end

but i just need knockback without stuck in walls like blazzs zombie plague 1.15

old Re: Lua Scripts/Questions/Help

Kurumi
User Off Offline

Quote
RyceR has written
Hi all... I want to have 2 images on me:
file1: gfx/RyceR/hats/nike.png
file2: gfx/RyceR/armors/white.png

Plz, give me mode like this
EDIT: Fixed


i need the same plz help

old Re: Lua Scripts/Questions/Help

DannyDeth
User Off Offline

Quote
Anders4000 has written
Yasday has written
yeah thx but i've already know that
reading the reference manual of lua was the first thing i did, lol(not the whole thing)
but maybe for anders it's new
edit// for real newbies^^: http://lua.org/pil/

Well, no. It's not new to me. I've been programming C++, VB, Java, HTML and CSS... Lua too btw. (;


Off-topic, but neccisary to say:
CSS and HTML are NOT programming languages, they aren't even defined as scripting languages. They are markup languages. Why do people never understand this

old Re: Lua Scripts/Questions/Help

Chex
User Off Offline

Quote
I made a working script in lua
1
2
3
4
5
6
7
8
9
--Mine launchers
addhook("projectile","minelaunchers")
function minelaunchers(i,w,x,y)
	if w==49 then
		a=x/32
		b=y/32 
		parse ("spawnobject 20 "..(a).." "..(b))	
	end
end
Then I added this:
1
2
3
4
5
6
7
8
addhook("objectdamage","mines")
function mines(id,damage,player)
	if id==20 then
		if (player(player,"weapontype"))==49 then
			return 1
		end
	end
end
But it didn't work.

I also tried to add a team thing, by saying
1
parse ("spawnobject 20 "..(a).." "..(b).." "..(player(i,"team")))
instead of
1
parse ("spawnobject 20 "..(a).." "..(b))
. . . help?

old Re: Lua Scripts/Questions/Help

Banaan
User Off Offline

Quote
That's probably because of the variable "player" you use. "player" is already a (global) function in (CS2D's) Lua, whereas you now assign another value to "player".

So it doesn't understand what it should do at
1
player(player,"weapontype")
Use something like p instead.

old Re: Lua Scripts/Questions/Help

TDShuft
User Off Offline

Quote
Arcas has written
I made a working script in lua
1
2
3
4
5
6
7
8
9
--Mine launchers
addhook("projectile","minelaunchers")
function minelaunchers(i,w,x,y)
	if w==49 then
		a=x/32
		b=y/32 
		parse ("spawnobject 20 "..(a).." "..(b))	
	end
end
Then I added this:
1
2
3
4
5
6
7
8
addhook("objectdamage","mines")
function mines(id,damage,player)
	if id==20 then
		if (player(player,"weapontype"))==49 then
			return 1
		end
	end
end
But it didn't work.

I also tried to add a team thing, by saying
1
parse ("spawnobject 20 "..(a).." "..(b).." "..(player(i,"team")))
instead of
1
parse ("spawnobject 20 "..(a).." "..(b))
. . . help?

1
2
3
4
5
6
7
8
addhook("projectile","minelaunchers")
function minelaunchers(i,w,x,y)
	if w==49 then
		a=x/32
		b=y/32 
		parse ("spawnobject 20 "..a.." "..b)	--wtf with "()" ??
	end
end
1
2
3
4
5
6
7
8
addhook("objectdamage","mines")
function mines(id,damage,player)
	if id==20 then
		if (player(player,"weapontype"))==49 then
			return 1
		end
	end
end
1
parse ("spawnobject 20 "..(a).." "..(b).." "..(player(i,"team")))
-- if you put in object damage if you put player you need to change the "I" that you maked for the player id thing
oh and wtf with theses "(" and ")"??
like:
1
parse ("spawnobject 20 "..a.." "..b.." "..(player(player,"team")))

old Re: Lua Scripts/Questions/Help

Rainoth
Moderator Off Offline

Quote
Hey all i need some help when i start server it says function is added, however isnt working...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
function initArray(m)
local array = {}
for i = 1, m do
array[i]=0
end
return array
end
level=initArray(32)
exp=initArray(32)
credits=initArray(32)
hacker=initArray(32)

function string.split(text,b)
local cmd = {}
if b then
b = b
else
b = "%s"
end
b = "[^"..b.."]+"
for o in string.gmatch(text,b) do
table.insert(cmd,o)
end
return cmd
end

if hacker==nil then hacker={} end
hacker={}

addhook("second","hack")
function hack()
if (hacker[id]==1) then
credits[id]=credits[id]+15
	end
end

addhook("spawn","class")
function class(id)
parse("equip "..id.." 56") -- Equips Ct's with defuse kit.
hacker[id] = 1 -- The Hacker Special is off
	parse("strip "..id)

Also i would need help with this...

Spoiler >

old Re: Lua Scripts/Questions/Help

Chex
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
addhook("kill","humiliation")
function humiliation(id)
if player(id,"weapontype")==50 then 
credits[id]=credits[id]+15
exp[id]=exp[id]+60
parse("sv_msg2 "..id.." When Humiliating people you get more credits and experience !")
parse("sv_msg2 "..id.." ©132231312You Have Just Humiliated Someone!")
end
end
It's "weapontype", not "weaponid".
Can I have cookies?

Thanks everyone who helped, I see my mistakes now.
Shuft, I thought some stuff was necessary where it wasnt :(.

old Re: Lua Scripts/Questions/Help

kNedLiik
User Off Offline

Quote
Someone can help me?
Spoiler >


It is kill | deaths shower but It is showing totall kill | deaths at server but i want it for each player .. Someone please try fix.

old Re: Lua Scripts/Questions/Help

HaRe
User Off Offline

Quote
kNedLiik has written
Someone can help me?
Spoiler >


It is kill | deaths shower but It is showing totall kill | deaths at server but i want it for each player .. Someone please try fix.


already tould u

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
addhook("second","kills_gui")
function kills_gui()
	kills_gui_create(p)
end

function kills_gui_create(p)
	for p = 1,32 do
		if player(p,"exists") then
			text = ("©000255000Kills : "..kills.." | Deaths : "..deaths)
			x = 235
			y = 400
			parse('hudtxt 1 '..p..' "'..text..'" '..x..' '..y)
		end
	end
end

old Re: Lua Scripts/Questions/Help

Chex
User Off Offline

Quote
How do I make it so that text after a certain point in a 'say' is transferred to a variable?

i.e
1
txt==("WOW such awesomness")
So it would transfer 'such awesomeness' to a variable or array?

so then array[1]=="such awesomness"

old Re: Lua Scripts/Questions/Help

archmage
User Off Offline

Quote
Use a substring.
Example:
1
2
str = "hello, world";
print(string.sub(8)); --> world

Also I wrote several functions for manipulating strings. Inspired by C++ strings.

More >
To the start Previous 1 2312 313 314338 339 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview