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 2124 125 126338 339 Nächste Zum Anfang

alt Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

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

alt Re: Lua Scripts/Questions/Help

Noxic
User Off Offline

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

alt Re: Lua Scripts/Questions/Help

Noxic
User Off Offline

Zitieren
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.
1× editiert, zuletzt 27.12.09 21:50:34

alt Re: Lua Scripts/Questions/Help

Vectarrio
User Off Offline

Zitieren
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?
1× editiert, zuletzt 27.12.09 22:46:13

alt Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Zitieren
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)
3× editiert, zuletzt 28.12.09 11:32:49

alt Adding effects in a script

Trotskygrad
User Off Offline

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

alt Re: Lua Scripts/Questions/Help

memo
COMMUNITY BANNED Off Offline

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

alt Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

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

alt Re: Lua Scripts/Questions/Help

Trotskygrad
User Off Offline

Zitieren
leegao hat geschrieben
memo hat geschrieben
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!"

alt Re: Lua Scripts/Questions/Help

memo
COMMUNITY BANNED Off Offline

Zitieren
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

alt Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Zitieren
memo hat geschrieben
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.
1× editiert, zuletzt 29.12.09 03:22:09

alt Re: Lua Scripts/Questions/Help

sonnenschein
User Off Offline

Zitieren
Flacko hat geschrieben
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
Zum Anfang Vorherige 1 2124 125 126338 339 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht