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 2312 313 314338 339 Nächste Zum Anfang

alt Re: Lua Scripts/Questions/Help

Yasday
User Off Offline

Zitieren
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
2× editiert, zuletzt 18.11.10 23:54:02

alt Re: Lua Scripts/Questions/Help

TWBiBi
User Off Offline

Zitieren
Admir hat geschrieben
@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

alt Re: Lua Scripts/Questions/Help

Admir
User Off Offline

Zitieren
TWBiBi hat geschrieben
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 =\

alt Re: Lua Scripts/Questions/Help

Anders4000
User Off Offline

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

alt KNOCKBACK

Jake-rus
User Off Offline

Zitieren
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

alt Re: Lua Scripts/Questions/Help

Kurumi
User Off Offline

Zitieren
RyceR hat geschrieben
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

alt Re: Lua Scripts/Questions/Help

DannyDeth
User Off Offline

Zitieren
Anders4000 hat geschrieben
Yasday hat geschrieben
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

alt Re: Lua Scripts/Questions/Help

Chex
User Off Offline

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

alt Re: Lua Scripts/Questions/Help

Banaan
User Off Offline

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

alt Re: Lua Scripts/Questions/Help

TDShuft
User Off Offline

Zitieren
Arcas hat geschrieben
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")))

alt Re: Lua Scripts/Questions/Help

Rainoth
Moderator Off Offline

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

alt Re: Lua Scripts/Questions/Help

Chex
User Off Offline

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

alt Re: Lua Scripts/Questions/Help

kNedLiik
User Off Offline

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

alt Re: Lua Scripts/Questions/Help

HaRe
User Off Offline

Zitieren
kNedLiik hat geschrieben
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

alt Re: Lua Scripts/Questions/Help

Chex
User Off Offline

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

alt Re: Lua Scripts/Questions/Help

archmage
User Off Offline

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

Mehr >
Zum Anfang Vorherige 1 2312 313 314338 339 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht