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 2315 316 317338 339 Next To the start

old Re: Lua Scripts/Questions/Help

Time
User Off Offline

Quote
Quote
EDIT: OMG, *facepalm* I just realised that this is the Lua help thread, my deepest apologies!


@DannyDeth
This happens to everyone once in a while, don't worry.

old Re: Lua Scripts/Questions/Help

Blocker
User Off Offline

Quote
@loooser

1
2
3
4
5
6
7
8
9
function checkweapon(id,weapon)
	local weapons = playerweapons(id)
	for i = 1, #weapons do
		if weapons[i] == weapon then
			return true
		end
	end
	return false
end

1
checkweapon(<id>,74)

old Re: Lua Scripts/Questions/Help

TDShuft
User Off Offline

Quote
can some 1 explain me the whole "image" Function please
i dont know much
well i know but
i tryed to "freeimg(id)"
but dont worked it needs the id of img but there are like over 47 imgs can some 1 help me ?
like how can i localizate a id of a img :S

old Re: Lua Scripts/Questions/Help

archmage
User Off Offline

Quote
The function image returns the images id.
Try something like:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
local loaded_images = {};

function load_image(path, mode, pl)
	mode = mode or 0;
	pl = pl or 0;

	local f = io.open(path);
	if ( f == nil ) then
		return error("can not find "..path);
	end
	f:close();
	
	table.insert(loaded_images, {[0]=path, id = image(path,0,0,mode,pl)});
	return loaded_images[#loaded_images]["id"];
end

Then if you want to find the path of an image
1
loaded_images[1][0];

and to call a function like freeimage
1
freeimage(loaded_images[1]["id"]);

old Re: Lua Scripts/Questions/Help

TDShuft
User Off Offline

Quote
Dark Byte has written
The function image returns the images id.
Try something like:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
local loaded_images = {};

function load_image(path, mode, pl)
	mode = mode or 0;
	pl = pl or 0;

	local f = io.open(path);
	if ( f == nil ) then
		return error("can not find "..path);
	end
	f:close();
	
	table.insert(loaded_images, {[0]=path, id = image(path,0,0,mode,pl)});
	return loaded_images[#loaded_images]["id"];
end

Then if you want to find the path of an image
1
loaded_images[1][0];

and to call a function like freeimage
1
freeimage(loaded_images[1]["id"]);

ty and is it that for creating img or i need to create it and call this functions ?

old Re: Lua Scripts/Questions/Help

archmage
User Off Offline

Quote
That will load an image and draw it to the screen.
Note: the starting position is (0,0) to set this to something else use imagepos

It also stores the path (the first parameter of the function) and the image id into the table loaded_images.

1
2
3
load_image("./graphics/weapons/bomb.bmp");
-- Some data on that image is stored in loaded_images
imagepos(loaded_images[#loaded_images].id, 50, 75, 0);

Replace the code I previously posted with this to make the new image data be stored at loaded_images[0]. and others are pushed back.
More >


Now it is like this:
1
2
3
4
5
6
load_image("splash.png") -- it is at loaded_images[0]
load_image("player.bmp")
--[[--
	Now the image player.bmp is at 0
	and splash.png is at 1
--]]--

old Re: Lua Scripts/Questions/Help

archmage
User Off Offline

Quote
Oh alright.

1
2
3
4
5
6
7
8
9
10
function findImageIDWithPath (path)
	local ret = {};
	for k, v in pairs(loaded_images) do
		if ( loaded_images[k][0] == path ) then
			table.insert(ret, 0, k);
		end
	end

	return ret;
end

old HELP !!!

Jake-rus
User Off Offline

Quote
Hey men ! i need help with this noworking script :
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
addhook("serveraction","za_action")
function za_action(id,action)
	if (action == 1) then
		if player(id,"team") == 2 then
			menu(id,"-SCORE POINTS-BUY MENU-,"..item[1].."|PRICE:".itemprice[1]..","..item[2].."|PRICE:".itemprice[2]..","..item[3].."|PRICE:".itemprice[3]..","..item[4].."|PRICE:".itemprice[4]..","..item[5].."|PRICE:".itemprice[5]..","..item[6].."|PRICE:".itemprice[6]..","..item[7].."|PRICE:".itemprice[7]..","..item[8].."|PRICE:".itemprice[8]..","..item[9].."|PRICE:".itemprice[9].."")
		end
	end
end

addhook("menu","za_menu")
function za_menu(id,title,key)
	if (title == "-SCORE POINTS-BUY MENU-") then

if (key == 1) then
if player(id,"score") >= itemprice[1] then
msg2(id,"©000200000BOUGHT:"..item[1].." FOR:"..itemprice[1].."|SCORE POINTS")
parse("setmaxhealth "..id.." 250")
parse("setarmor "..id.." 200")
parse("setscore "..id.." "..player(id,"score")-itemprice[1].."")

if (key == 2) then
if player(id,"score") >= itemprice[2] then
msg2(id,"©000200000BOUGHT:"..item[2].." FOR:"..itemprice[2].."|SCORE POINTS")
parse("speedmod "..id.." 10")
parse("setscore "..id.." "..player(id,"score")-itemprice[2].."")

if (key == 3) then
if player(id,"score") >= itemprice[3] then
msg2(id,"©000200000BOUGHT:"..item[3].." FOR:"..itemprice[3].."|SCORE POINTS")
noreload[id] = 1
parse("setscore "..id.." "..player(id,"score")-itemprice[3].."")

end
end
end
end
end
end
end
end

old Re: Lua Scripts/Questions/Help

Danikah
User Off Offline

Quote
Hey everyone!
Someone linked a bot AI which shoots NPCs. Can somebody tell me where can I download that bot AI?

EDIT: Nothing, I found it.
edited 1×, last 24.11.10 12:42:26 pm

old Re: Lua Scripts/Questions/Help

kNedLiik
User Off Offline

Quote
Arcas has written
How do you find out if a player is vip?
Is it "look"? If so, which llook?

just use the
string.find(...) function to find the name of player and put names in
vips = {"name1,name2,name3"}

old Re: Lua Scripts/Questions/Help

Anders4000
User Off Offline

Quote
Jake-rus has written
Spoiler >


Think that your if-statements was a little bugged with the ends..
Haven't tried it, but i believe this works. (:
- Anders4000

PS. Edited your post.

old Re: Lua Scripts/Questions/Help

Chex
User Off Offline

Quote
kNedLiik has written
Arcas has written
How do you find out if a player is vip?
Is it "look"? If so, which llook?

just use the
string.find(...) function to find the name of player and put names in
vips = {"name1,name2,name3"}

That's not what I mean. I mean to find the vip in assassination game mode.

old Re: Lua Scripts/Questions/Help

Ice-cream16
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
addhook("movetile","mypos")
function mypos(id,x,y)
        parse('hudtxt2 ..id.. 9 "©255255255Your Tile X,Y '..x..' and '..y..'" 13 350 0')
end

addhook("move","mypos2")
function mypos2(id,x,y,walk)
        parse('hudtxt2 ..id.. 10 "©255255255Your X,Y '..x..' and '..y..'" 13 380 0')
end
This script by manucrazy. I found here ©255255255 - this is color. Where i can look all codes of colors?

old Re: Lua Scripts/Questions/Help

Chex
User Off Offline

Quote
1
parse("hudtxt2 "..align.." "..i.." "'..text..'" "..x.." "..y)
This is the only line I'm having trouble with...
The debugger says ')' expected near '('.
I don't see any open parenthesese.

old Re: Lua Scripts/Questions/Help

kNedLiik
User Off Offline

Quote
Arcas has written
1
parse("hudtxt2 "..align.." "..i.." "'..text..'" "..x.." "..y)
This is the only line I'm having trouble with...
The debugger says ')' expected near '('.
I don't see any open parenthesese.

hudtxt is totally bad..
1
parse('hudtxt '..id..' "'..text..'" '..x..' '..y)
or
1
parse('hudtxt2 '..id..' '..idd..' "'..text..'" '..x..' '..y..' '..align)

Someone help:

Will i use this :
1
if (player(id,"name") == "newbie") then
or i can use
1
if player(id,"name") == "newbie" then

and one more question:

can i reaplace the id,message in
1
2
addhook("say","example")
function example(id,message)
with something like this
1
2
addhook("say","example")
function example(p,t)
and then if i want call the id i just use p and for message just t?
Please answer.
edited 2×, last 24.11.10 09:36:29 pm
To the start Previous 1 2315 316 317338 339 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview