Forum

> > CS2D > Scripts > Bring & Teleport for Hc
Forums overviewCS2D overview Scripts overviewLog in to reply

English Bring & Teleport for Hc

7 replies
To the start Previous 1 Next To the start

old Bring & Teleport for Hc

Man Of Steel
User Off Offline

Quote
Hi Guys,

I'm editing hc admin script, i wanted to add Bring and Teleport in F3 menu so i added this code for that, check

Spoiler >



Spoiler >


Spoiler >


But Code not working, even no errors
Anybody can help me pls.
I'm not Scripter i just edit script.

old Re: Bring & Teleport for Hc

Rainoth
Moderator Off Offline

Quote
What he said applies but more so than that, you're attaching functions (in first spoiler which you shouldn't even add because it doesn't contain a lot of code) that do not exist, so the menu calls a function that's nil and nothing happens.

hc.moderation.bring_command
~=
function hc.moderation.bring(id, arg)

Same thing for teleport.

In the future when you don't get errors, look at every single detail one by one and check if it's working. Even the very obvious things.

Good luck.

old Re: Bring & Teleport for Hc

Rainoth
Moderator Off Offline

Quote
You don't put any comparisons or anything.

You defined function "function hc.moderation.bring(id, arg)" yet you're telling HC to call function "hc.moderation.bring_command". Those are two different functions and the one you didn't define obviously doesn't exist, so nothing happens.

To put it in the most simple terms, this is what you've done:

1
2
3
4
5
function a()
  print("woohoo")
end

b()

b() doesn't exist, only a() but you're calling b(). You're doing the same thing with your functions.

old Re: Bring & Teleport for Hc

G3tWr3ck3d
User Off Offline

Quote
Inside file
1
hc/core/util.lua
add

1
2
3
4
5
6
7
8
9
10
11
12
function hc.isAlive(p, id)	
	if (player(id,"team") == hc.T or player(id,"team") == hc.CT) then
		if player(id, "health") > 0 then
			return true
		else
			hc.error(p, "This player is dead.")
		end
	else
		hc.error(p, "This player is spectating.")
	end
	return false
end

Inside file
hc/modules/moderation.lua
add this code inside function
1
function hc.moderation.init()

1
2
hc.add_menu_command("Bring", hc.moderation.bring_command, hc.MODERATOR1, hc.ADMIN_MENU_KEY, { category = "Moderate" })	
	hc.add_menu_command("GoTo", hc.moderation.goto_command, hc.MODERATOR1, hc.ADMIN_MENU_KEY, { category = "Moderate" })

Search for
1
-- Menu commands
comment and add

1
2
3
4
5
6
7
function hc.moderation.bring_command(p)
    hc.show_menu(p, "Bring", hc.get_players(), hc.moderation.bring)
end

function hc.moderation.goto_command(p)
    hc.show_menu(p, "GoTo", hc.get_players(), hc.moderation.goto)
end

Search for
1
-- Menu callbacks
comment and add

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
function hc.moderation.bring(p, _, item)
    local id = item.id

	if hc.isAlive(p, id) then
		hc.exec(p, "setpos " .. id .. " " .. player(p, "x") .. " " .. player(p, "y"))
	end
end

function hc.moderation.goto(p, _, item)
    local id = item.id

	if hc.isAlive(p, id) then
		hc.exec(p, "setpos " .. p .. " " .. player(id, "x") .. " " .. player(id, "y"))
	end
end

You are done √
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview