Forum

> > CS2D > General > [Finnaly Solved] God on own server?
Forums overviewCS2D overviewGeneral overviewLog in to reply

English [Finnaly Solved] God on own server?

15 replies
To the start Previous 1 Next To the start

old [Finnaly Solved] God on own server?

VegBerg
User Off Offline

Quote
•This problem IS solved, you can read the thread anyway for experience

Is it possible to have a "godmode" on your own server?

I have a construction server where I will try to make it so it's not too many turrets on one team...
edited 3×, last 22.07.10 02:54:29 pm

old Re: [Finnaly Solved] God on own server?

VegBerg
User Off Offline

Quote
Yorty has written
Go ask in the lua help thread. And a godmode script is easy.

I tried to make one my self first:

1
2
3
4
5
6
7
8
adhook("hit", "health")
function health(player, player, weapon, >0, >0)
	if player(id,"usgn") == 62805 then
		return 1
	else
		return 0
	end
end

old Re: [Finnaly Solved] God on own server?

VegBerg
User Off Offline

Quote
Focus2D has written
You want godmode, so you can go around and kill everyone else. Because you don't have the skills required, to play fair.

No, because they're not following the rules. In con_* they are not allowed to build turrets or gate fields in the enemy base... Many people give shitt in the rules so I'm removing turrets

I found an alternative way to do it too:
bind "k" "sethealth "ID" 100"

edit: Thank you, Flacko.

old Re: [Finnaly Solved] God on own server?

Focus2D
User Off Offline

Quote
VegBerg has written
I found an alternative way to do it too:
bind "k" "sethealth "ID" 100"



That's not god mode, 1 awp shot and your down. Unless you edit the awp's damage.

A better option would be:
1
bind "k" "setmaxhealthhealth "ID" 250"

old Re: [Finnaly Solved] God on own server?

VegBerg
User Off Offline

Quote
I tried to make it more advanced but get an error at line 4

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
addhook("say","god")
function god(player, text)
   if msg("!godmode 1") then
		if player(id,"usgn") == 62805 then
			return 1
			adhook("hit", "health")
			function health(id, src)
				if player(id,"usgn") == 62805 then return 1 else return 0 end
			end
		else
			return 0
		end
	else
		if msg("!godmode 0" then
			adhook("hit", "health")
			function health(id, src)
				if player(id,"usgn") == 62805 then return 0 else return 0 end
			end
		
	end
end

old Re: [Finnaly Solved] God on own server?

DC
Admin Off Offline

Quote
the variable "id" has no value. you used the variable "player" instead (function god(player,text).
either change player to id or id to player.

old Re: [Finnaly Solved] God on own server?

HaRe
User Off Offline

Quote
VegBerg has written
I tried to make it more advanced but get an error at line 4

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
addhook("say","god")
function god(player, text)
   if msg("!godmode 1") then
		if player(id,"usgn") == 62805 then
			return 1
			adhook("hit", "health")
			function health(id, src)
				if player(id,"usgn") == 62805 then return 1 else return 0 end
			end
		else
			return 0
		end
	else
		if msg("!godmode 0" then
			adhook("hit", "health")
			function health(id, src)
				if player(id,"usgn") == 62805 then return 0 else return 0 end
			end
		
	end
end


Maybe this one works

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
addhook("hit","godemode_hit")
addhook("say","godmode_say")
function godmode_say(id,txt)
	if (player(id,"usgn") == 62805) then
		if (txt=="!godmode 1") then
			return 1
			function godmode_hit(id,weapon)
				if (weapon==weaponID) then
					parse("setmaxhealth "..id.." 250")
		elseif (txt=="!godmode 0") then
			return 1
			function godmode_hit(id,weapon)
				if (weapon==weaponID) then
		end
	end
end

/edit

the error you found in

1
if player(id,"usgn") == 62805 then

is the
1
== 62805
and the
1
if player

it should look like this

1
if (player(id,"usgn") == 62805) then

old Re: [Finnaly Solved] God on own server?

HaRe
User Off Offline

Quote
umm i think this works

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
weaponhit=0 

addhook("say","godmode_say")
function godmode_say(id,txt)
	if (player(id,"usgn") == 62805) then
		if (txt=="!godmode 1") then
			weaponhit=1
			return 1
		elseif (txt=="!godmode 0") then
			weaponhit=0
			return 1
		end
	end
end

addhook("hit","godemode_hit")
function godemode_hit(id,source,weapon,hpdmg,apdmg)
	if (weapon==ID and weaponhit==1) then
		parse("setmaxheatlh "..id.." 250")
	elseif (weapon==ID and weaponhit==0) then
		print("GodMode off")
	end
end

/edit Thanks DC
edited 1×, last 22.07.10 01:53:18 pm

old Re: [Finnaly Solved] God on own server?

DC
Admin Off Offline

Quote
the "godemode_hit" function is using wrong variable names. moreover it uses the variable "ID" which is not defined (at least if lua makes a difference between id and ID, idk)
the correct hit event parameters are
1
hit(id,source,weapon,hpdmg,apdmg)
note: weapon is the third parameter, not the second

keep godmode_say and replace godemode_hit with
1
2
3
4
5
6
addhook("hit","godmode_hit")
function godmode_hit(id)
	if (player(id,"usgn")==62805 and weaponhit==1) then
		return 1
	end
end

say "!godmode 1" to activate godmode

old Re: [Finnaly Solved] God on own server?

VegBerg
User Off Offline

Quote
DC has written
the "godemode_hit" function is using wrong variable names. moreover it uses the variable "ID" which is not defined (at least if lua makes a difference between id and ID, idk)
the correct hit event parameters are
1
hit(id,source,weapon,hpdmg,apdmg)
note: weapon is the third parameter, not the second

keep godmode_say and replace godemode_hit with
1
2
3
4
5
6
addhook("hit","godmode_hit")
function godmode_hit(id)
	if (player(id,"usgn")==62805 and weaponhit==1) then
		return 1
	end
end

say "!godmode 1" to activate godmode


Thank you, It works... Anyway it looks like you guys need to help me more later with Lua I hope I can get that good as you guys are some day

PROBLEM SOLVED

edit: Console says LUA ERROR: Attempt to call a nil value
To the start Previous 1 Next To the start
Log in to replyGeneral overviewCS2D overviewForums overview