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 256 57 58338 339 Next To the start

old Re: Lua Scripts/Questions/Help

playa slaya
COMMUNITY BANNED Off Offline

Quote
nevermind i found it out but i need to know two last things
how to increase
1
parse("setmaxhealth "..id.." +example")  by    example = 5
and how to make a random thing and i know what i need to
edited 1×, last 19.09.09 04:09:15 am

old Re: Lua Scripts/Questions/Help

Admir
User Off Offline

Quote
I need help here, just a newbie questions.
how to make that only player have unlimited ammo?
not for all player unlimited ammo.

old Re: Lua Scripts/Questions/Help

ohaz
User Off Offline

Quote
playa slaya has written
how can i make the game remember something after you leave the server?
You need to write it with Lua scripts and io commands.
http://www.lua.org/pil/21.1.html
and the next chapter.
Quote
I need help here, just a newbie questions.
how to make that only player have unlimited ammo?
not for all player unlimited ammo.

You could write the script in a way that it fills the ammo of one person everytime he reloads. Then there is no "unlimited" image, but it works too

old Re: Lua Scripts/Questions/Help

playa slaya
COMMUNITY BANNED Off Offline

Quote
so would this work
1
io.input[my script] t = io.read("*all)
well i did not understand much of that page but will continue reading

old Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Quote
playa slaya has written
so would this work
1
io.input[my script] t = io.read("*all)
well i did not understand much of that page but will continue reading

well, I guess not.

This is super hero 1.2 save script (values save) :

1
2
3
4
5
6
7
function sh_pl_save(id)
	if (player(id,"usgn") > 0) then [b]-- Saves for U.S.G.N.[/b]
		file = assert(io.open(sh_sv_dir..''..player(id,"usgn")..'.txt','w')) [b]-- Makes file with usgn id name. [/b]
		file:write(pl_xp[id]) [b]-- pl_xp is experience valuable[/b]
		file:close()
	end
end

And reading (For newest script Im using shorter way) :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
function sh_pl_load(id)
	if pl_load[id] == 0 then
		if (player(id,"usgn") > 0) then
			local usgn = player(id, "usgn")
			ld_data = io.open(sh_dir..'sh_data/'..player(id,"usgn")..'.txt','r')
			if (ld_data ~= nil) then
				for line in io.lines(sh_dir..'sh_data/'..player(id,"usgn")..'.txt','r') do
					local parses = totable(line)
					if (tonumber(parses[1]) > 0) then
						pl_xp[id] = tonumber(parses[1])
						ld_data:close()
					end
				end
			end
		end
		pl_load[id] = 1
	end
end

old Re: Lua Scripts/Questions/Help

playa slaya
COMMUNITY BANNED Off Offline

Quote
yes i know i meant well ill show u
1
2
3
4
addhook("attack2","mine")
function mine(id)
How to select weapon attatack from mose 1 or mouse 2??
end
read the script

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
playa slaya has written
yes i know i meant well ill show u
1
2
3
4
addhook("attack2","mine")
function mine(id)
How to select weapon attatack from mose 1 or mouse 2??
end
read the script


If you want to detect if the player is using burst-mode or not, use the "mode" parameter.

old Re: Lua Scripts/Questions/Help

playa slaya
COMMUNITY BANNED Off Offline

Quote
so it would be
if (mode==1) then or if (mode==2) then

but i need help with somthing more imporatant:

sorry to bother you again ,but i must know why this isnt working the script works perfect except for saveing it wont save so could u help
1
2
3
4
5
6
7
8
9
10
11
12
13
------------------
-- Save --
------------------
-- This was by: Blazzingxx      thanks blazzing
addhook("leave","rpg_leave_save")
function rpg_leave_save(id)
	if (player(id,"usgn") > 0) then -- Saves for U.S.G.N. 
          file = assert(io.open(RPG_data_dir..''..player(id,"usgn")..'.txt','w')) -- Makes file with usgn id name. 
          file:write(experience[id])
		  file:write(level[id])
          file:close() 
    end 
end

and Load
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
------------------
--   Join    --    the  save\load  by: Blazzingxx    thanks blazzing
------------------
addhook("join","rpg_load") 
	function rpg_load(id) 
     if load[id] == 0 then 
          if (player(id,"usgn") > 0) then 
               local usgn = player(id, "usgn") 
               ld_data = io.open(dir..'RPG_data folder/'..player(id,"usgn")..'.txt','r') 
               if (ld_data ~= nil) then 
                    for line in io.lines(dir..'RPG_data folder/'..player(id,"usgn")..'.txt','r') do 
                         local parses = totable(line) 
                         if (tonumber(parses[1]) > 0) then 
                              pl_xp[id] = tonumber(parses[1]) 
                              ld_data:close() 
                         end 
                    end 
               end 
          end 
          load[id] = 1 
     end 
end

all i have is my script and a folder for saves named
RPG_data folder

the code [ code ] [ /code ] did not use tabs

old Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Quote
I will fix your save and load, just wait some time... I have to do something else first

btw, dont use load function for loading!
Use team hool, join[p] = 0 then player joins game.
edited 1×, last 20.09.09 12:40:41 pm

old Re: Lua Scripts/Questions/Help

Admir
User Off Offline

Quote
can someone make me a simple script that only no reload for 1 player, not all player, I still need a time to learn it

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
Slaya, you had an extra quote and forgot to concatenate the "/"
1
file = assert(io.open(RPG_data_dir.."/"..player(id,"usgn")..".txt",'w'))

That should work
However, I hate saving in diferent files for each USGN
Also, you are saving the experience and the level in the same word. Ie: If have 10XP and im level 2, the file would look like "102". Write to the file like this:
1
file:write(experience[id],"\n",level[id])
edited 1×, last 20.09.09 02:59:13 pm

old Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Quote
@Flacko
This is idea in gun game 1.1
There is stats values:
Kills, Deaths, Knifekills, Points, Shots, Hits, Wins.
In file data i looks like that (Load & Save scripts much smaller):

1
2
3
4
5
6
7
5
4
1
5
35
28
0

Use "\n" to make new line.

Btw, believe... Its faster to load/save smaller file.
Instead of loading/saving huge file.

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
Blazzingxx has written
Use "\n" to make new line.

Btw, believe... Its faster to load/save smaller file.
Instead of loading/saving huge file.


OFC it's faster, but file input/output isn't slow by itself, so I just don't care about speed and make it more confortable for me

BTW: I fixed the script to make it work, I think I should have read thw whole loading function Dx

old closed uzzi

uzzi
User Off Offline

Quote
nu mia mersi deloc nici admin si de culoare nimica am pus tot ce trebuia: (

Admin/mod comment

English only plz /TheKilledDeath

old Re: Lua Scripts/Questions/Help

playa slaya
COMMUNITY BANNED Off Offline

Quote
well i am working on attributes for my rpg and i am on my second 1 athletics.the script works perfect until level up
then i get a million messages in console saying well iforgot it works untill level up on levl 1 to level 2
but its at line 166
Spoiler >

@flacko
could i make this happen on leave to save and i do not have dir will it still work?

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
I don't know, I never tried that
Post your leveling function and write here exactly what the console console prints whenever you get the error.
Edit: Ouch, your code has really messed up indentations (tabs) and some 'end's don't match their 'if's.
To the start Previous 1 256 57 58338 339 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview