Forum

> > CS2D > Scripts > Lua Scripts/Questions/Help
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Lua Scripts/Questions/Help

6.770 Antworten
Seite
Zum Anfang Vorherige 1 255 56 57338 339 Nächste Zum Anfang

alt Re: Lua Scripts/Questions/Help

DC
Admin Off Offline

Zitieren
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.

alt Re: Lua Scripts/Questions/Help

ohaz
User Off Offline

Zitieren
DC hat geschrieben
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)

alt Re: Lua Scripts/Questions/Help

4erteg
User Off Offline

Zitieren
TheKilledDeath hat geschrieben
DC hat geschrieben
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)

alt Re: Lua Scripts/Questions/Help

playa slaya
COMMUNITY BANNED Off Offline

Zitieren
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?

alt Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Zitieren
playa slaya hat geschrieben
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

alt Re: Lua Scripts/Questions/Help

playa slaya
COMMUNITY BANNED Off Offline

Zitieren
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?

alt Re: Lua Scripts/Questions/Help

playa slaya
COMMUNITY BANNED Off Offline

Zitieren
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

alt Re: Lua Scripts/Questions/Help

ohaz
User Off Offline

Zitieren
playa slaya hat geschrieben
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

alt Re: Lua Scripts/Questions/Help

saladface27
User Off Offline

Zitieren
Zitat
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

alt Re: Lua Scripts/Questions/Help

GreatRit
COMMUNITY BANNED Off Offline

Zitieren
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

alt Re: Lua Scripts/Questions/Help

playa slaya
COMMUNITY BANNED Off Offline

Zitieren
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

alt Re: Lua Scripts/Questions/Help

Admir
User Off Offline

Zitieren
playa slaya hat geschrieben
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

alt Re: Lua Scripts/Questions/Help

LilCoder
BANNED Off Offline

Zitieren
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 --.
Zum Anfang Vorherige 1 255 56 57338 339 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht