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 2272 273 274338 339 Next To the start

old Re: Lua Scripts/Questions/Help

Snake_Eater
User Off Offline

Quote
Hey guys I need help...at this script.....

1
2
3
4
5
6
7
8
9
10
11
addhook ("join","namewrite")
function namewrite(p)
for v in io.lines("names.txt") do
    if (player(p,"name")~=v) then 
	break 
	end
    local file = assert(io.open("names.txt" , "a"))
    file:write(""..player(p,"name").."\n")
    file:close()
end
end

I have a text file (names.txt) and I want if somebody join and if the name hasn't been already written in text file the computer write it in like in a "Collectnames script".
But my version doesn't work.....
help pls

old Re: Lua Scripts/Questions/Help

HaRe
User Off Offline

Quote
Snake_Eater has written
Hey guys I need help...at this script.....

1
2
3
4
5
6
7
8
9
10
11
addhook ("join","namewrite")
function namewrite(p)
for v in io.lines("names.txt") do
    if (player(p,"name")~=v) then 
	break 
	end
    local file = assert(io.open("names.txt" , "a"))
    file:write(""..player(p,"name").."\n")
    file:close()
end
end


I have a text file (names.txt) and I want if somebody join and if the name hasn't been already written in text file the computer write it in like in a "Collectnames script".
But my version doesn't work.....
help pls


i think this should work

1
2
3
4
5
6
7
8
9
10
11
12
addhook ("join","namewrite")
function namewrite(p)
	for v in io.lines("names.txt") do
		if (player(p,"name") == v) then 
			--
		else
  			local file = assert(io.open("names.txt" , "a"))
			file:write(""..player(p,"name").."\n")
			file:close()
		end
	end
end

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
addhook ("join","namewrite")
function namewrite(p)
	local function findline(txt)
		for v in io.lines("names.txt") do
			if v == txt then
				return true
			end
		end
		return false
	end
	
	if not findline(player(p,"name")) then
		local file = assert(io.open("names.txt" , "a"),"ERROR, CANNOT FIND FILE")
		file:write(player(p,"name").."\n")
		file:close()
	end
end

old .YeaH.

FiiD
User Off Offline

Quote
Can any say me what is wrong on this script???

1
2
3
4
5
6
addhook("break","money") 
function money(x,y)
if x==x and y==y then 
	parse("setmoney "..id.." "..player(id,"money")+1000)
    end  
end

I need this script for my new map...

old Re: Lua Scripts/Questions/Help

Rainoth
Moderator Off Offline

Quote
FiiD has written
addhook("break","money")
function money(x,y)
if x==x and y==y then
parse("setmoney "..id.." "..player(id,"money")+1000)
end
end


Maybe you should type x and y cordinates instead of x and y letters

old Re: Lua Scripts/Questions/Help

pivot
User Off Offline

Quote
Tajifun has written
1
2
3
4
5
6
7
8
addhook("say","Adminsay")
function Adminsay(id,txt)
	-- Admin equip A
	if (txt=="!a12345") then
		parse("speedmod "..id.." 20")
		return 1
	end
end

That should work.


The Return 1 don't worked!
edited 1×, last 04.10.10 08:37:18 pm

old Re: Lua Scripts/Questions/Help

RyceR
User Off Offline

Quote
1
2
3
4
5
6
addhook("say","Adminsay")
function Adminsay(id,txt)
	 if (txt=="!a12345") then
		parse("speedmod "..id.." 20")
	end
end
try this...

old Re: Lua Scripts/Questions/Help

HaRe
User Off Offline

Quote
pivot has written
Tajifun has written
1
2
3
4
5
6
7
8
addhook("say","Adminsay")
function Adminsay(id,txt)
	-- Admin equip A
	if (txt=="!a12345") then
		parse("speedmod "..id.." 20")
		return 1
	end
end

That should work.


The Return 1 don't worked!


do you use another Say Hook function on your scripts? then please dont do that, that wil lfuck up your script completely

you can 0nly use 1 say hook on the whole script

old Re: Lua Scripts/Questions/Help

Tajifun
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
addhook("break","money")
function money(x,y)
for id=1,32 do
if player(id,"exists") then
if x == NUMBER OF BREAKABLE X and y == NR. OF BRE. Y then
bonusmoney = player(id,"money")+1000
parse("setmoney "..id.." "..bonusmoney.."")
end
end
end
end

Try this.
IDK if it works. :]


@ pivot
let lua check the usgn id!
example:
1
2
3
4
5
6
7
addhook("spawn","Admin")
function Admin(id)
     if player(id,"usgn") == 8529 then -- Change 8529 with your usgn
          parse("speedmod "..id.." 20")
          msg2(id,"You are an Admin!") -- remove this if you want. :D
     end
end

Good Luck :b
edited 1×, last 05.10.10 04:45:42 pm

old Re: Lua Scripts/Questions/Help

pivot
User Off Offline

Quote
Tajifun has written
1
2
3
4
5
6
7
8
9
10
11
addhook("break","money")
function money(x,y)
for id=1,32 do
if player(id,"exists") then
if x == NUMBER OF BREAKABLE X and y == NR. OF BRE. Y then
bonusmoney = player(id,"money")+1000
parse("setmoney "..id.." "..bonusmoney.."")
end
end
end
end

Try this.
IDK if i work. :]


@ pivot
let lua check the usgn id!
example:
1
2
3
4
5
6
7
addhook("spawn","Admin")
function Admin(id)
     if player(id,"usgn") == 8529 then -- Change 8529 with your usgn
          parse("speedmod "..id.." 20")
          msg2(id,"You are an Admin!") -- remove this if you want. :D
     end
end

Good Luck :b


Perfect! Thanks!

old Re: Lua Scripts/Questions/Help

FiiD
User Off Offline

Quote
batlaizys has written
FiiD has written
addhook("break","money")
function money(x,y)
if x==x and y==y then
parse("setmoney "..id.." "..player(id,"money")+1000)
end
end


Maybe you should type x and y cordinates instead of x and y letters


No sorry...it dont works...

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
shuft has written
how i fade a weapon if its spawned ( spawned i mean with parse("spawnitem bla bla")...
plz help


Instead of using parse use this function:

1
2
3
4
5
6
7
8
9
10
11
function spawnitem(id,x,y)--This one
	parse("spawnitem "..id.." "..x.." "..y)
	local a = item(0,"table")
	a = a[#a]
	timer(tonumber(game("mp_weaponfadeout"))*1000,"parse","removeitem "..a,1)
end

addhook("collect","_collect")
function _collect(id,iid)
	freetimer("parse","removeitem "..iid)
end

old Re: Lua Scripts/Questions/Help

Tajifun
User Off Offline

Quote
@ FiiD

How I already said:
Try this

1
2
3
4
5
6
7
8
9
10
11
addhook("break","money")
function money(x,y)
for id=1,32 do
if player(id,"exists") then
if x == BREAKABLE X and y == BREAKABLE Y then -- Fill in the posistion of the breakable
bonusmoney = player(id,"money")+1000
parse("setmoney "..id.." "..bonusmoney.."")
end
end
end
end

If you brea the wall at x == your breakable X and y = your breakable Y you will get 1000$.

old Re: Lua Scripts/Questions/Help

Blacko
User Off Offline

Quote
Hello, I need help please ! I have RP server, but the server don't save money and license ... I test many script for save, but nobody run ... Please help me !
I hope you answer me !
Thanks you all ...
To the start Previous 1 2272 273 274338 339 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview