Forum

> > CS2D > Scripts > Resetscore/Maxmoneyall/Automoney
Forums overviewCS2D overview Scripts overviewLog in to reply

English Resetscore/Maxmoneyall/Automoney

7 replies
To the start Previous 1 Next To the start

moved Resetscore/Maxmoneyall/Automoney

ImBack
User Off Offline

Quote
Yes, this might be closed, might as well try.

Okay so I installed amx2d thinking perhaps it might have the commands in the thread title resetscore/maxmoneyall/automoney.

So what I'm looking is how to set these commands in my server so..

typing !resetscore - would reset your score
or @maxmoneyall - to give people all money
@automoney - basically giving everyone 16000 every rounsd.

Anyone have scripts and ways on how to set this up?

Yes, I'm a noob at this. Sorry for such a request.
Thank you if you can help me out.

Admin/mod comment

please note that there is a scripts section! use it instead of the general section please! moved!

old Re: Resetscore/Maxmoneyall/Automoney

Banaan
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
addhook("say","scoreandmoney")
addhook("startround","setmoney")

automoney = false

scoreandmoney = function (id, txt)
	if txt == "resetscore" then
		parse("setscore "..id.." 0")
		parse("setdeahts "..id.." 0")
	elseif txt == "@maxmoneyall" then
		for _,id in ipairs(player(0,"tableliving")) do parse("setmoney "..id.." 16000") end
	elseif txt == "@automoney" then
		if automoney then automoney = false else automoney = true end
	end
end

setmoney = function ()
	if automoney then
		for _,id in ipairs(player(0,"tableliving")) do parse ("setmoney "..id.." 16000") end
	end
end

That should work (unless there's typo's in there, haven't tested)

old Re: Resetscore/Maxmoneyall/Automoney

ImBack
User Off Offline

Quote
Wow, I was sure I posted this in the scripts area... sorry about that DC.

Thanks Banaan
The @maxmoneyall works great!
You're my savior, thank you so much

Now I can host servers without people complaining about money all the time.

Thank you again!!

old Re: Resetscore/Maxmoneyall/Automoney

Flacko
User Off Offline

Quote
Hmm

1
if automoney then automoney = false else automoney = true end

Use
1
automoney = not automoney
Looks better and it's shorter.

1
for x,y in ipairs(stuff)
Don't use ipairs anymore. It's getting deprecated in Lua 5.2. Use pairs() instead, there won't be any difference at all because the player(0,"tablestuff") only returns numerical indexes.

old Re: Resetscore/Maxmoneyall/Automoney

Lee
Moderator Off Offline

Quote
@Flacko: o_O, is ipairs really getting deprecated? That seems a little weird since there's no other list traversal natives that returns elements ordered by the index

old Re: Resetscore/Maxmoneyall/Automoney

Lee
Moderator Off Offline

Quote
hmm, that is rather alarming as the 5.2 W2 version introduced the __ipairs metamethod. I don't know, I've always preferred the
1
for index,value in ipairs(tbl)
construct over its numerical equivalent
1
2
3
for i=1,#tbl
	local value = tbl[i]
    ...

Following this vein of rationale, we might as well just remove for loops entirely as they are basically syntactical enhancements over while loops, and since while loops are (at a low level) congruent to recursive calls, we should just do away with all loops, in fact, we should all just ditch Lua and start writing our programs in Scheme which offers no iterative conditionals whatsoever <_<

anyways, using the iterator paradigm in Lua, we can always write our own ipairs

1
2
3
4
5
function ipairs_(tbl)
	return function(tbl, i) if tbl[i+1] ~= nil then return i+1,tbl[i+1] end end, tbl, 0
end

for i,v in ipairs_{1,2,3,4,5} do print(i,v) end

Albeit from what I'm reading in the 5.2 review, it seems that ipairs now uses #tbl instead

1
2
3
4
function ipairs_(tbl)
	local m = #tbl
	return function(tbl, i) if i<m then return i+1,tbl[i+1] end end, tbl, 0
end
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview