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 2124 125 126338 339 Next To the start

old Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Quote
Hmm? Hook adding function requires "string".
addhook(Hook,"Function String")
Anyway, your function is working now...

× I haven't tried, but it shouldn't work like this:
1
2
-- Probably it's returning integer (nil valuable) in this case...
addhook(always,my_function)

old Re: Lua Scripts/Questions/Help

Noxic
User Off Offline

Quote
When I use the 'strip' command on an inventory item I get an error message. Is it impossible to remove non-weapons?

Also waiting for the ammo changing script Blazzingxx mentioned two pages ago. I've looked into it, but I really can't find a way to do this (unless there's some hidden/invisible 'player' or 'item' table with variables that change their respective properties).

old Re: Lua Scripts/Questions/Help

Noxic
User Off Offline

Quote
What about forcing teams?

I can force a teamchange if someone chooses the team I don't want them to join, but then they automaticly switch back to their team of choice after they die (which they do when I force the teamchange). Maybe a way to remove the team from the menu?

EDIT: Also, I'm still curious about hidden tables. Anything undocumented, in fact.
edited 1×, last 27.12.09 09:50:34 pm

old Re: Lua Scripts/Questions/Help

Vectarrio
User Off Offline

Quote
Yes, black, but can I use exactly |255,0,255| color?
piece: I want to draw a tile from tileset, but I dont want to make many tiles cropped from that tileset
Just I am going to do Stereoscopic thing (Exactly:Anaglyph)

And How to turn string into the value?
edited 1×, last 27.12.09 10:46:13 pm

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
You should try different blending modes and see if one of them works.
As far as I know, you can't blit a rectangle from a bitmap with CS2D's functions.
If you want to turn a string into a number, you sould use tonumber(), if you want to call a function thru a string, you should put your function inside a table and call it like this
1
2
3
4
5
6
epic_table={
	function da_function(a_string)
		print(a_string)
	end
}
epic_table["da_function"]("A printed text") --Here we call the function

Or you could use metatables but that would be too complicated and maybe even useless in this case

Edit: Oh sorry, I fail terribly, you don't need to put the functions in a table, you can simply call your function from the main table _G["Your function"](Your parameters)
edited 3×, last 28.12.09 11:32:49 am

old Adding effects in a script

Trotskygrad
User Off Offline

Quote
I would like to use the "effect" command in a script. HOwever,this requires me to use two sets of quotes, which lua assumes is not part of the quote (the code is
parse("effect "colorsmoke" "..player(, etc.

old Re: Lua Scripts/Questions/Help

memo
COMMUNITY BANNED Off Offline

Quote
ok i make script for my new mod but i donot why it dosen't
work the hook is add to game ( i see it from console) but nothing happen, its about that when your HP goes under 50 a msg pop up and tell you " you are Hurt,Get Covered" but when i start the game and my Hp gose under 50 a msg on console that shows Lua error the "player" must have a nil number somthing like that ? what wrong on it ?

Spoiler >

old Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Quote
memo has written
ok i make script for my new mod but i donot why it dosen't
work the hook is add to game ( i see it from console) but nothing happen, its about that when your HP goes under 50 a msg pop up and tell you " you are Hurt,Get Covered" but when i start the game and my Hp gose under 50 a msg on console that shows Lua error the "player" must have a nil number somthing like that ? what wrong on it ?

Spoiler >


1
2
3
4
5
6
addhook("hit","cod4.hit")
function cod4.hit(id)
	if player(id,"health") < 50 then
		msg2(id, "You are hurt, Get Cover!")
	end
end

old Re: Lua Scripts/Questions/Help

Trotskygrad
User Off Offline

Quote
leegao has written
memo has written
ok i make script for my new mod but i donot why it dosen't
work the hook is add to game ( i see it from console) but nothing happen, its about that when your HP goes under 50 a msg pop up and tell you " you are Hurt,Get Covered" but when i start the game and my Hp gose under 50 a msg on console that shows Lua error the "player" must have a nil number somthing like that ? what wrong on it ?

Spoiler >


1
2
3
4
5
6
addhook("hit","cod4.hit")
function cod4.hit(id)
	if player(id,"health") < 50 then
		msg2(id, "You are hurt, Get Cover!")
	end
end


lol, sorry to interrupt (leegao's code should work, I've done that stuff before). Shouldn't it be... "You are badly hurt, get to cover!"

old Re: Lua Scripts/Questions/Help

memo
COMMUNITY BANNED Off Offline

Quote
thanks Trotsygrad but this msg come after i die i want it befroe dieing ?? like when my HP go on 49 the msg come on middle of the scrren thats what i want but thanks any way

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
memo has written
thanks Trotsygrad but this msg come after i die i want it befroe dieing ?? like when my HP go on 49 the msg come on middle of the scrren thats what i want but thanks any way


You should thank leegao.
And this won't work very well if you get hit by an RPG/2xZ.AWP/Laser in case you were testing the script with those guns.
edited 1×, last 29.12.09 03:22:09 am

old Re: Lua Scripts/Questions/Help

sonnenschein
User Off Offline

Quote
Flacko has written
You should thank leegao.
And this won't work very well if you get hit by an RPG/2xZ.AWP/Laser.

Can't you add a code that returns 0 if certain weapon hit you?

1
2
3
4
5
6
7
8
9
10
addhook("hit","cod4.hit")
function cod4.hit(id,source,weapon,hpdmg,apdmg)
	if player(id,"health") < 50 then
		if "weapon = bla bla" then
			return 0
		else
			msg2(id, "You are hurt, Get Cover!")
		end
	end 
end
To the start Previous 1 2124 125 126338 339 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview