Forum

> > CS2D > Scripts > Add god in the menu.
Forums overviewCS2D overview Scripts overviewLog in to reply

English Add god in the menu.

8 replies
To the start Previous 1 Next To the start

old Add god in the menu.

Mora
User Off Offline

Quote
Hello, someone can add God mode in this menu?
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
owner = {114940}
ons=false
parse("sv_fow 0")

addhook("serveraction","_s")
function _s(id,key)
 for _,usgn in ipairs(owner) do 
  if player(id,"usgn")==usgn then
if key==1 then
menu(id,"Menu,Fog Of War|"..getboleantype(ons).."")
  end
 end
end
end

addhook("menu","_m")
function _m(id,title,b)
if title=="Menu" then
if b == 1 then
if ons==true then
ons=false
parse("sv_fow 0")
else
ons=true
parse("sv_fow 1")
end
menu(id,"Menu,Fog Of War|"..getboleantype(ons).."")
end
end
end

function getboleantype(var)
if var==false then
return "OFF"
elseif var==true then
return "ON"
end
end
this will work, like a F.O.W. when press it,I got God mode and button will "ON",off then "OFF".
thanks

old Re: Add god in the menu.

Marcell
Super User Off Offline

Quote
Spoiler >


Works like charm, because i tested it

old Re: Add god in the menu.

VADemon
User Off Offline

Quote
Provides a code snippet that works for only one player - Proves it by testing it on his own.
user Marcell has written
Works like charm, because i tested it


~The code is too derpy to edit. You have a typo in "getboleantype" - it's "boolean"

UPD: Working code:
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
owner = {114940, 7844, 1, 42}
ons=false
parse("sv_fow 0")
godMode={}

addhook("hit","_hit")
function _hit(id)
     if godMode[id] then
          return 1
     end
end

addhook("leave","godmode_reset")
function godmode_reset(id)
	godMode[id] = nil
end


addhook("serveraction","_s")
function _s(id,key)
     for _,usgn in ipairs(owner) do 
		msg("Checking usgn ".. usgn)
		if player(id,"usgn")==usgn then
			if key==1 then
				menu(id,"Menu,Fog Of War|"..getbooleantype(ons)..",GOD Mode|" ..boolToStr( godMode[id]).. "") 
			end
          end
     end
end

addhook("menu","_m")
function _m(id,title,b)
	if title=="Menu" then
		if b == 1 then
			if ons==true then
				ons=false
				parse("sv_fow 0")
			else
				ons=true
				parse("sv_fow 1")
			end
			menu(id,"Menu,Fog Of War|"..getbooleantype(ons)..",GOD Mode|" ..boolToStr( godMode[id]).. "")
		elseif b == 2 then
			godMode[ id ] = not godMode[ id ] -- toggle god mode state
			godModeMessage(id)
			menu(id,"Menu,Fog Of War|"..getbooleantype(ons)..",GOD Mode|" ..boolToStr( godMode[id]).. "")
		end
	end

end

function godModeMessage(id)
	msg2(id, "©000255125God mode was ".. (godMode[id] and "en" or "dis") .. "abled for you!")
end


function getbooleantype(var)
     if var==false then
          return "OFF"
     elseif var==true then
          return "ON"
     end
end

-- booleanToString
-- this not only checks against TRUE|FALSE but also for NIL
-- 		existing elements (tables, numbers etc.) count as TRUE ("ON") while not existing ones like NIL return "OFF"
function boolToStr( val )
    if val then
		return "ON"
	end
	return "OFF"	
end
edited 1×, last 13.03.14 10:20:47 am

old Re: Add god in the menu.

UnkN
User Off Offline

Quote
Spoiler >


Happy Fun

old Re: Add god in the menu.

Danel Matto
BANNED Off Offline

Quote
user Marcell has written
Spoiler >


Works like charm, because i tested it

Wow Thanks help you
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview