Forum

> > CS2D > Scripts > Free for all script request
Forums overviewCS2D overview Scripts overviewLog in to reply

English Free for all script request

10 replies
To the start Previous 1 Next To the start

old Free for all script request

Kevindurant
User Off Offline

Quote
Hi I was wondering if u guys can make a script for me.

If i say !ffa

it makes the rcon go
sv_gamemode 1 / mp_radar 0 / mp_respawndelay 5

and then when i say !ffa . a 2nd time
it'll make all the settings go back to normal like it'll be standard gamemode with radar back to being enabled and no respawn delay

----------------------------------------
Also to accompany this script (A SEPERATE ONE) I want it so that if you were to take damage and after 2 seconds of not taking damage you heal an "x" amount of hp per second

so basically if u do
!heal5 >> you will heal 5 seconds per second if you weren't damaged in the past 2 seconds

Also i want to be able to change the amount of health u heal per second from like !heal0 (disabled) ranging to !heal100 (heal 100 health per second)

so the command

!heal(x)

(x) being any number from 1-100 healing per second and "0" disabling the script

--------
Thank you for anyone able to complete this request for me, and if u are confused as to what I'm asking reply to this topic or pm me.

-KEVINDURANT THE BEST NBA PLAYER

old Re: Free for all script request

boncuk
User Off Offline

Quote
Here is the code:
Spoiler >


I know you're using a server hosted by another person, and you havent the vps for config the admin file, so, just implement / approach this in the main code and test it, i already tested it with TopNoch's Admin, Idk what's admin script are you usign so... this is all i can do...

old Re: Free for all script request

Kevindurant
User Off Offline

Quote
idk what u said but i want the thing hand fed to me so i give it to the hoster and he has no problems with it and uploads the script in 5 minutes plus are u able to do the 2nd script i requested?

old Re: Free for all script request

Rainoth
Moderator Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
function string.split(str,pat) -- Splitting strings (sentences) into separate words
    local t = {}
    for word in string.gmatch(str,pat or "[^%s]+") do
        t[#t+1] = word
    end
    return t
end

heal = {}

addhook("join","_sp")
function _sp(id)
	heal[id] = {}
	heal[id].timer = 2
	heal[id].regen = 0
end

addhook("say","_s")
function _s(id,txt)
	local arg = txt:split()
	if arg[1] == "!heal" then
		for _, id in pairs (player(0,"table")) do
			heal[id].regen = tonumber(arg[2])
		end
		return 1
	end
end

addhook("second","_sec")
function _sec()
	for _,id in pairs (player(0,"tableliving")) do
		if heal[id] then
			if heal[id].timer == 0 then
				parse("sethealth "..id.." "..player(id,"health")+heal[id].regen)
			elseif heal[id].timer > 0 then
				heal[id].timer = heal[id].timer - 1
			end
		end
	end
end

addhook("hit","_h")
function _h(id, s)
	if heal[id] then
		heal[id].timer = 2
	end
end
edited 2×, last 04.01.17 01:54:58 am

old Re: Free for all script request

GeoB99
Moderator Off Offline

Quote
@user Kevindurant: I ran the script just to check it out and this is what I've got:
[14:20:37] Fraizeraust: !heal 5
[14:20:37] LUA ERROR: sys/lua/test.lua:25: attempt to index field '?' (a nil value)
[14:20:37]  -> sys/lua/test.lua:25: in function <sys/lua/test.lua:22>

That means you're trying to access the table key which it doesn't exist or has no value what-so-ever. From 22 to 32 line replace the part of the code with this one. It should work now.
1
2
3
4
5
6
7
8
9
10
11
function _sec()
     for k,v in pairs (player(0,"tableliving")) do
          if heal[v] then
               if heal[v].timer == 0 then
                    parse("sethealth "..v.." "..player(v,"health")+heal[v].regen)
               elseif heal[v].timer > 0 then
                    heal[v].timer = heal[v].timer - 1
               end
          end
     end
end
In any case if a script doesn't work or stops working, you must check the Console for Lua errors marked in red. These outputs are necessary for troubleshoot.

old Re: Free for all script request

Rainoth
Moderator Off Offline

Quote
@user Kevindurant: Whoops, I did a very dumb mistake and used 'id' when in reality I should have used 'v' (cause my loop was 'k, v' not '_, id' like I usually write). I fixed the code so it should throw no errors there now.

old Re: Free for all script request

boncuk
User Off Offline

Quote
@Kevindurant: Its cos that the script not works, i already test it, and the cmds of Admins Script make interference with the !heal cmd, just tell to hoster approach into the main code

old Re: Free for all script request

Kevindurant
User Off Offline

Quote
Panyko I tried the script alone in the Lua but it wouldn't work, as you said it depends on topnoch's admin script do you or someone else pls mind turning it into a standalone script one that I can use just on its own by itself. Thank you very much if u or someone can do this for me

old Re: Free for all script request

Rainoth
Moderator Off Offline

Quote
@user Kevindurant: Take my code and after line 25, add
1
2
3
4
5
6
elseif arg[1] == "!ffa" then
	if game("sv_gm")==1 then
		-- parse your settings to bring back everything to normal
	else
		-- parse your settings to set everything up for deathmatch
	end
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview