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 2169 170 171338 339 Next To the start

old Re: Lua Scripts/Questions/Help

goweiwen
User Off Offline

Quote
I tried using freetimer(), but I can't seem to add anymore timers after doing that. I was hoping there was a way to do it, I want to make buffs for my script.

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
Hey guys, here I have fixed my bitmap mini-library:
Spoiler >

I've got to fix my problem with png images
The above script will load an image file.

If the image is a Windows BMP file, the script will store it's file size, width, height and color depth in a table under the fsize,w,h and bpp keys respectively and return the table.

If the image happens to be a PNG file, only the w and h values will be read.

Also, the format of the image and it's path will be stored in the typ and dir keys respectively (regardless if the file is a BMP or PNG file)

old Re: Lua Scripts/Questions/Help

goweiwen
User Off Offline

Quote
@Vectar
Yup, I planned to do that, but I wanted to do some less hacky stuff because there is already a timer() function implemented.

@Flacko
Nice, I might use it to help me position images properly.

old Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Quote
Flacko has written
Hey guys, here I have fixed my bitmap mini-library:
Spoiler >

I've got to fix my problem with png images
The above script will load an image file.

If the image is a Windows BMP file, the script will store it's file size, width, height and color depth in a table under the fsize,w,h and bpp keys respectively and return the table.

If the image happens to be a PNG file, only the w and h values will be read.

Also, the format of the image and it's path will be stored in the typ and dir keys respectively (regardless if the file is a BMP or PNG file)


Ahaha, glad to see other people using my work to destroy the wor.. I mean do good

old Re: Lua Scripts/Questions/Help

Noxic
User Off Offline

Quote
Is there a way to change the names for player "looks"? That is, the looks you can choose in the menu directly after choosing team.

old Re: Lua Scripts/Questions/Help

Kaka024
User Off Offline

Quote
i modified smb's script because i wanted to make credit-system on server. What's wrong with these lines?:

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
function load(id)
     usgn = player(id,"usgn")
     if (usgn > 0) then
          local usgn = player(id, "usgn")
          files = io.open("sys/lua/dh/"..usgn..".txt","r") 
          if(files~=nil) then
               msg2(id,"©160160255Your U.S.G.N ID: "..usgn.."@C")
               msg2(id,"©000255000Your Save file found!@C")
               parse('hudtxt2 '..id..' 100 "©000255000Login as: '..usgn..'" 40 415')
               for line in io.lines("sys/lua/dh/"..usgn..".txt","r") do 
               local parses = totable(line)
           
               dh.credits = tonumber(parses[1])
               break
     end
     else          msg2(id,"©255000000Failed to load save!@C")
          msg2(id,"©255000000Please check your U.S.G.N account settings!@C")
          parse('hudtxt2 '..id..' 100 "©255000000Failed to Load Save" 40 415')
     end
     else
          parse('hudtxt2 '..id..' 100 "©255000000Failed to Login!" 40 415')
          msg2(id,"©255000000Please check your U.S.G.N account settings!@C")
     end
end 

addhook("join","wata")
function wata(id)
load(id)
end
It doesn't read stats, it doesn't return any message in-game/console (file is ready, saving system works)

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
try this
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
function load(id)
	local usgn = player(id,"usgn")
	if (usgn > 0) then
		files = io.open("sys/lua/dh/"..usgn..".txt","r")
		if(files) then
			msg2(id,"©160160255Your U.S.G.N ID: "..usgn.."@C")
			msg2(id,"©000255000Your Save file found!@C")
			parse('hudtxt2 '..id..' 100 "©000255000Login as: '..usgn..'" 40 415')
			local parses = totable(files:read("*a"))
			dh.credits = tonumber(parses[1])
		else
			msg2(id,"©255000000Failed to load save!@C")
			msg2(id,"©255000000Please check your U.S.G.N account settings!@C")
			parse('hudtxt2 '..id..' 100 "©255000000Failed to Load Save" 40 415')
		end
		files:close()
	else
		parse('hudtxt2 '..id..' 100 "©255000000Failed to Login!" 40 415')
		msg2(id,"©255000000Please check your U.S.G.N account settings!@C")
	end
end

addhook("join","wata")
function wata(id)
	load(id)
end

old Re: Lua Scripts/Questions/Help

Vectarrio
User Off Offline

Quote
Blazzingxx has written
How did you used it?
Show the script.

I used it for older versions of CS2D for doom3 mod.
I doesnt have it now, but it was smth like:
1
2
3
4
5
6
7
addhook("spawn","d3_spawn")
function d3_spawn(id)
	if(player(id,"look")==1) then
		parse("equip "..id.." 75)
	elseif other 3 times
	end
end
it worked, but It equipped weapon to player with wrong look

old Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Quote
Starkkz has written
Flacko, you forgot something..
1
if (files[b]~=nil[/b]) then


1
if(files) then

file can either === true or is none

old Re: Lua Scripts/Questions/Help

Kaka024
User Off Offline

Quote
Flacko has written
try this
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
function load(id)
	local usgn = player(id,"usgn")
	if (usgn > 0) then
		files = io.open("sys/lua/dh/"..usgn..".txt","r")
		if(files) then
			msg2(id,"©160160255Your U.S.G.N ID: "..usgn.."@C")
			msg2(id,"©000255000Your Save file found!@C")
			parse('hudtxt2 '..id..' 100 "©000255000Login as: '..usgn..'" 40 415')
			local parses = totable(files:read("*a"))
			dh.credits = tonumber(parses[1])
		else
			msg2(id,"©255000000Failed to load save!@C")
			msg2(id,"©255000000Please check your U.S.G.N account settings!@C")
			parse('hudtxt2 '..id..' 100 "©255000000Failed to Load Save" 40 415')
		end
		files:close()
	else
		parse('hudtxt2 '..id..' 100 "©255000000Failed to Login!" 40 415')
		msg2(id,"©255000000Please check your U.S.G.N account settings!@C")
	end
end

addhook("join","wata")
function wata(id)
	load(id)
end

Doesn't work, still no message and no loading credits. If this is important - i use local server hosted by option New Game.

@edit
when i use dedicated server (where my usgn isn't found) the fail message shows. But when i make straight from new game it doesn't say anything. On dedicated server i recieved error (finally)

1
ERROR: hudtxt(2) - text id out of bounds (0-49 expected)!

but i think it doesn't have anything with the rest of the code, i'll try changing text to shorter anyway.
To the start Previous 1 2169 170 171338 339 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview