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 255 56 57338 339 Next To the start

old Re: Lua Scripts/Questions/Help

DC
Admin Off Offline

Quote
with cs2d cmd setmoney
1
2
3
4
money=player(ID,"money") --get the money
money=money-100 --decrease it by 100
if money<0 then money=0 end --you probably don't need that line
parse("setmoney "..ID.." "..money) --set the new money value

will subtract 100$ for example. ID has to be replaced with the player id of course.

old Re: Lua Scripts/Questions/Help

ohaz
User Off Offline

Quote
DC has written
with cs2d cmd setmoney
1
2
3
4
money=player(ID,"money") --get the money
money=money-100 --decrease it by 100
if money<0 then money=0 end --you probably don't need that line
parse("setmoney "..ID.." "..money) --set the new money value

will subtract 100$ for example. ID has to be replaced with the player id of course.
This code can of course be made much shorter:
1
parse("setmoney "..ID.." "..player(id, "money")-100)

old Re: Lua Scripts/Questions/Help

4erteg
User Off Offline

Quote
TheKilledDeath has written
DC has written
with cs2d cmd setmoney
1
2
3
4
money=player(ID,"money") --get the money
money=money-100 --decrease it by 100
if money<0 then money=0 end --you probably don't need that line
parse("setmoney "..ID.." "..money) --set the new money value

will subtract 100$ for example. ID has to be replaced with the player id of course.
This code can of course be made much shorter:
1
parse("setmoney "..ID.." "..player(id, "money")-100)


big thx)

old Re: Lua Scripts/Questions/Help

playa slaya
COMMUNITY BANNED Off Offline

Quote
is there a hook for typing keys for example:
1
2
3
4
5
6
addhook("type","example_type")
function example_type(id,type)
	if(type=="L") then
		parse("strip "..id.." 32")
	end
end
also is my spacing correct for script?

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
playa slaya has written
is there a hook for typing keys for example:
1
2
3
4
5
6
addhook("type","example_type")
function example_type(id,type)
	if(type=="L") then
		parse("strip "..id.." 32")
	end
end
also is my spacing correct for script?


Yep your tabbing is right, however, CS2D doesn't have such a hook, you can use the "use" key, serveractions and reload instead

old Re: Lua Scripts/Questions/Help

playa slaya
COMMUNITY BANNED Off Offline

Quote
well that sucks maybe DC will make that.but i need to know if i got this write:

- = subtraction

+ = adding

* = multiply

/ = division

> = below a number

< = above a number

is that right?

old Re: Lua Scripts/Questions/Help

playa slaya
COMMUNITY BANNED Off Offline

Quote
whats the code for hudtext i tried
1
hudtext(id,1,"forgot what i put")
did not work

also is it possible to increase stuff like this:
1
example = 98

old Re: Lua Scripts/Questions/Help

ohaz
User Off Offline

Quote
playa slaya has written
well that sucks maybe DC will make that.
No. the 3 serveraction keys should be enough. It's good that DC made this because people would get very surprised if their config suddenly does something else than what they told it to do

old Re: Lua Scripts/Questions/Help

saladface27
User Off Offline

Quote
Quote
1
2
3
4
5
Code:
variable = {0,0}

function readValues()
...


I think it's a bit better this way:
1
2
3
4
variable = {0,0}

function readValues()
...
[/quote]

thanks lilcoder and flacko

old Re: Lua Scripts/Questions/Help

GreatRit
COMMUNITY BANNED Off Offline

Quote
An unban script.
Can someone script a unban script so you can unban a certain person?
like @unbanusgn 35385
@unbanip 1.1.1.1
@unbanname pwned

old Re: Lua Scripts/Questions/Help

playa slaya
COMMUNITY BANNED Off Offline

Quote
i cant have hud i tried:
1
2
3
4
5
6
addhook("join","my_join")
function my_join()
	for  i=1,32 do
		parse('hudtxt2 '..i..' 1 "©255000000example"225 455')
	end
end

old Re: Lua Scripts/Questions/Help

Admir
User Off Offline

Quote
playa slaya has written
i cant have hud i tried:
1
2
3
4
5
6
addhook("join","my_join")
function my_join()
	for  i=1,32 do
		parse('hudtxt2 '..i..' 1 "©255000000example"225 455')
	end
end


you forget this?
1
if player(i,"exists") then

I don't know if it not working

old Re: Lua Scripts/Questions/Help

LilCoder
BANNED Off Offline

Quote
try this:

1
2
3
4
5
6
7
8
9
10
11
color = {red  = "©255000000", green = "©000255000", blue = "©000000255"}
function hudtxt2(id,slot,clr,txt,x,y,a)
	parse('hudtxt2 '..id..' '..slot..' "'..color[clr]..''..txt..'" '..x..' '..y..' '..a..'')
end

addhook("join","my_join")
function my_join(id)
	--for p in ipairs(player(0,"table")) do
	hudtxt2(id, 1, "red", "Welcome to my server!", 225, 455, 0)
	--end
end

Your code will print a message to everybody's screen whenever a player has joined.
which is possible too with your for loop, if that's what you want You should then remove the --.
To the start Previous 1 255 56 57338 339 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview