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 2138 139 140338 339 Next To the start

old I'm Bruno R Z

BrunoRZ
User Off Offline

Quote
Hi everyone, I'm trying to make a lua script for my weapon shop. (I'm actually desperated)
I want a button, then the player press it, and buy a grenade, ( loses 400$, and get the grenade equiped)
I never made a lua script before, whats wrong whit that one?

---------------------------------------------------------------------------

addhook("use","weaponshop")
function weaponshop(id,trigger)
     if trigger=="HE" then
     if (player(id,"money")>399 then
          parse("setmoney"..id.." "..player(id,"money")-400)
          parse("equip"..id.." "..player(id,"51")")
               end
          end
     end

old Re: Lua Scripts/Questions/Help

ohaz
User Off Offline

Quote
info.txt has written
use(id,event,data,x,y)     on use
-id: player id
-event: use event (1 h.follow,2 h.stop,3 defuse, 100 tr._use, 150 dyn obj.)
-data: additonal data
-x: use x (tiles) or hostage id
-y: use y (tiles)

the use hook does not work in the way you used it.

old Re: Lua Scripts/Questions/Help

Redefinder
User Off Offline

Quote
Mod-_er_- has written
need help for the healing stuff

when you hit someone with the machete, the guy gain 10hp.

1
2
3
4
5
6
addhook("hit","machete")
function machete(id,source,weapon,hpdmg,apdmg)
	if(weapon == 69) then
parse ("sethealth "..id.." "..player(id,"health") + 10)
	end
end
This should work,try it!
edited 2×, last 16.01.10 10:47:29 am

old Re: Lua Scripts/Questions/Help

Redefinder
User Off Offline

Quote
Blazzingxx has written
@redefinder,
Hook should be returned.

Won`t that make that weapon to cause no damage?I think Mod-_er_- means that you can kill with a machete not just hit.

old Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Quote
redefinder has written
Won`t that make that weapon to cause no damage?I think Mod-_er_- means that you can kill with a machete not just hit.
If you wanna to make sethealth, setarmor or other stuff in hit hook, you have to return hook.
At least you should know what you are talking about.
Your code isn't healing at all.

Machete Healing:
1
2
3
4
5
6
7
addhook("hit","machete")
function machete(id,source,w,hpdmg,apdmg)
	if (w == 69) then
		parse ("setmaxhealth "..id.." "..player(id,"health") + 10)
		return 1
	end
end

@Mod-_er_-,
You were asking for healing...
His script have a mistake, that's why it has no healing...
edited 1×, last 16.01.10 10:48:13 am

old Re: Lua Scripts/Questions/Help

Starkkz
Moderator Off Offline

Quote
Who is the author of this? if can give me the permission to use it, please.


Spoiler >

old Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Quote
CmDark has written
@Starkkz
the author would be 'Flacko'

Not really right.

Those sin(), cos() functions culculations were used long time ago.
Maybe standartrad function, but it returns only angle.
I and other guys also made scripts like that some time ago.

This stuff is used almost in all 2D games, so there is no real author.

old Re: Lua Scripts/Questions/Help

BrunoRZ
User Off Offline

Quote
TheKilledDeath has written
info.txt has written
use(id,event,data,x,y)     on use
-id: player id
-event: use event (1 h.follow,2 h.stop,3 defuse, 100 tr._use, 150 dyn obj.)
-data: additonal data
-x: use x (tiles) or hostage id
-y: use y (tiles)

the use hook does not work in the way you used it.


using all this, how my lua should stay???, i never made one before

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
That's not mine.
Fortunately, I've got enough english knowledge to know that the right word is "standard".
And I think the function standartrad isn't working properly, since I've got one that works perfect and doesn't look like that one.

old Re: Lua Scripts/Questions/Help

Homer
User Off Offline

Quote
@redefinder Eh, I meant we had similar ideas, My script doesn't look much like yours, but okay.
Question:
I've gone on to work on cmds, I understand one line but I don't get how you do multiple line cmds.
So, like saying equip 1 in the console gives the person a
weapon. Could someone show me a script like that? I'd really appreciate it

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
Do you remember the toTable function?
It splits a string into tokens and returns a table with it's words.
for example
1
toTable("this is a string")
would return
1
{"this","is","a","string"}

And here you have an example:
1
2
3
4
5
6
7
addhook("say","command_say")
command_say(id,txt) --whatever
	local splitted_cmd = toTable(txt)--Here we get the table and store it
	if splitted_cmd[1]:lower()=="!equip" --Here we compare the first word with !equip
		parse("equip "..id.." "..splitted_cmd[2])--We parse the command (and I guess that the second parameter is the weapon)
	end
end

old Re: Lua Scripts/Questions/Help

Homer
User Off Offline

Quote
So, you don't need the hook parse? Im confused, since I want to type this in a console. but, What does this have to do with a table, Sorry for my poor learning, and thanks for the examples And I was curious on how to set a persons id as the second value, like say
equip 1 83
would give a id 1 super armor(note: I just want to know how to do this :D)

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
Oh, yes you need the parse hook.
I did it with the say hook just in case
If you haven't understood what I explained in the other post you should read it again.
To the start Previous 1 2138 139 140338 339 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview