Forum

> > CS2D > Scripts > Usgn image
Forums overviewCS2D overview Scripts overviewLog in to reply

English Usgn image

19 replies
To the start Previous 1 Next To the start

old Usgn image

D-D3ADxPro
User Off Offline

Quote
I was wondering how you could get a image to act like a usgn. If you do have a usgn, the hudtxt will show at the image saying "USGN '..player(id,"usgn")..'". If you don't have a usgn, it will just show "Not Registered!"

Heres my script that I tried to do:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
addhook("startround","_usgnprohud")
function _usgnprohud()
	local id=image("gfx/GoPro/usgn.png",0,0,2)
	imagealpha(id,1.0)
	imagepos(id,334,374,0)
end

addhook("startround","_usgnhudtxt")
function _usgnhudtxt()
	if (player(id,"usgn")>0) then
	parse('hudtxt2 '..id..' 26 "©255128000USGN: '..player(id,"usgn")..'" 292 363')
	msg2(id,"©000255000Logged in as "..player(id,"usgn").."!")
else
	parse('hudtxt2 '..id..' 26 "©255000000Not Registered!" 292 363')
	msg2(id,"©255000000You don't have a USGN! Log-in or register!")
end

The console just shows up a LUA ERROR: attempt to call a nil value. And it just spams up the whole console.

old Re: Usgn image

_Yank
User Off Offline

Quote
In that function called _usgnhudtxt. There's no id parameter (line 10).
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
addhook("startround","_usgnprohud")
function _usgnprohud()
     local id=image("gfx/GoPro/usgn.png",0,0,2)
     imagealpha(id,1.0)
     imagepos(id,334,374,0)
end

addhook("startround","_usgnhudtxt")
function _usgnhudtxt()
	 local pl_count=game("sv_maxplayers")
     for i = 1,pl_count
     if (player(i,"usgn")>0) then
     parse('hudtxt2 '..i..' 26 "©255128000USGN: '..player(i,"usgn")..'" 292 363')
     msg2(id,"©000255000Logged in as "..player(i,"usgn").."!")
else
     parse('hudtxt2 '..i..' 26 "©255000000Not Registered!" 292 363')
     msg2(id,"©255000000You don't have a USGN! Log-in or register!")
end

old Re: Usgn image

D-D3ADxPro
User Off Offline

Quote
1
LUA ERROR: sys/lua/AdminScript/server.lua:172: 'do' expected near 'if'

Line 12 in your script has an error.

old Re: Usgn image

_Yank
User Off Offline

Quote
Oh didnt notify o.O
It was your fault.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
addhook("startround","_usgnprohud")
function _usgnprohud()
	local id=image("gfx/GoPro/usgn.png",0,0,2)
	imagealpha(id,1.0)
	imagepos(id,334,374,0)
end

addhook("startround","_usgnhudtxt")
function _usgnhudtxt()
	local pl_count=game("sv_maxplayers")
	for i = 1,pl_count
		if (player(i,"usgn")>0) then
		parse('hudtxt2 '..i..' 26 "©255128000USGN: '..player(i,"usgn")..'" 292 363')
		msg2(id,"©000255000Logged in as "..player(i,"usgn").."!")
	else
		parse('hudtxt2 '..i..' 26 "©255000000Not Registered!" 292 363')
		msg2(id,"©255000000You don't have a USGN! Log-in or register!")
	end
end
Please learn how to use tabs, im sure that will help you a lot.

old Re: Usgn image

Infinite Rain
Reviewer Off Offline

Quote
@user _Yank:
No, it's your fault.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
addhook("startround","_usgnprohud")
function _usgnprohud()
     local id=image("gfx/GoPro/usgn.png",0,0,2)
     imagealpha(id,1.0)
     imagepos(id,334,374,0)
end

addhook("startround","_usgnhudtxt")
function _usgnhudtxt()
     local pl_count=game("sv_maxplayers")
     for i = 1,pl_count do
          if (player(i,"usgn")>0) then
          parse('hudtxt2 '..i..' 26 "©255128000USGN: '..player(i,"usgn")..'" 292 363')
          msg2(id,"©000255000Logged in as "..player(i,"usgn").."!")
     else
          parse('hudtxt2 '..i..' 26 "©255000000Not Registered!" 292 363')
          msg2(id,"©255000000You don't have a USGN! Log-in or register!")
     end
end

old Re: Usgn image

_Yank
User Off Offline

Quote
@user Infinite Rain:
No, that was our fault.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
addhook("startround","_usgnprohud")
function _usgnprohud()
     local id=image("gfx/GoPro/usgn.png",0,0,2)
     imagealpha(id,1.0)
     imagepos(id,334,374,0)
end

addhook("startround","_usgnhudtxt")
function _usgnhudtxt()
     local pl_count=game("sv_maxplayers")
     for i = 1,pl_count do
          if (player(i,"usgn")>0) then
          parse('hudtxt2 '..i..' 26 "©255128000USGN: '..player(i,"usgn")..'" 292 363')
          msg2(i,"©000255000Logged in as "..player(i,"usgn").."!")
     else
          parse('hudtxt2 '..i..' 26 "©255000000Not Registered!" 292 363')
          msg2(i,"©255000000You don't have a USGN! Log-in or register!")
     end
end

old Re: Usgn image

_Yank
User Off Offline

Quote
@user D-D3ADxPro:
Was your fault again ._.
And please try to do a better use of your brain, i believe it has potential. Why was you using startround hook ?
IMG:https://oi39.tinypic.com/1imud5.jpg

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
addhook("startround","_usgnprohud")
function _usgnprohud()
     local id=image("gfx/GoPro/usgn.png",0,0,2)
     imagealpha(id,1.0)
     imagepos(id,334,374,0)
end

addhook("spawn","_usgnhudtxt")
function _usgnhudtxt(id)
	if (player(id,"usgn")>0) then
		parse('hudtxt2 '..id..' 26 "©255128000USGN: '..player(id,"usgn")..'" 292 363')
		msg2(id,"©000255000Logged in as "..player(id,"usgn").."!")
	else
		parse('hudtxt2 '..id..' 26 "©255000000Not Registered!" 292 363')
		msg2(i,"©255000000You dont have a USGN! Log-in or register!")
	end
end
edited 4×, last 28.07.13 07:16:31 pm

old Re: Usgn image

Gajos
BANNED Off Offline

Quote
Replace this:
1
parse('hudtxt2 '..id..' 26 "©255128000USGN: '..player(id,"usgn")..'" 292 363')
on this:
1
parse('hudtxt2 '..id..' 26 "©255128000USGN: '..player(id,'usgn')..'" 292 363')

old Re: Usgn image

_Yank
User Off Offline

Quote
user brofistmsia has written
Best if use autorun scripts. It always work for me.

You mean samples, and dont talk when you dont know what we're talking about. You dont know lua ? Stay away of this posts.

old Re: Usgn image

D-D3ADxPro
User Off Offline

Quote
Lua Error

Heres the full script:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
addhook("startround","_usgnprohud")
function _usgnprohud()
     local id=image("gfx/GoPro/usgn.png",0,0,2)
     imagealpha(id,1.0)
     imagepos(id,334,374,0)
end

addhook("startround","_usgnhudtxt")
function _usgnhudtxt(i,p)
     local pl_count=game("sv_maxplayers")
     for i = 1,pl_count do
          if (player(i,"usgn")>0) then
          parse('hudtxt2 '..i..' 26 "©255128000USGN: '..player(i,"usgn")..'" 292 363')
          msg2(p,"©000255000Logged in as "..player(i,"usgn").."!")
     else
          parse('hudtxt2 '..i..' 26 "©255000000Not Registered!" 292 363')
			msg2(p,"©255000000You don't have a USGN! Log-in or register!")
		 end
     end
end
Tried to change the "id" to "p" in the msg2's but they dont seem to work. Also, everytime I move a tile, IT will flood it with: LUA ERROR: attempt to call a nil value

old Re: Usgn image

_Yank
User Off Offline

Quote
Why you're not using the script i post above ? -.-
Why are you using startround hook ?

old Re: Usgn image

_Yank
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
addhook("join","_usgnprohud")
function _usgnprohud(id)
     local id=image("gfx/GoPro/usgn.png",0,0,2)
     imagealpha(id,1.0)
     imagepos(id,334,374,0)
end

addhook("join","_usgnhudtxt")
function _usgnhudtxt(id)
     if (player(id,"usgn")>0) then
          parse('hudtxt2 '..id..' 26 "©255128000USGN: '..player(id,"usgn")..'" 292 363')
          msg2(id,"©000255000Logged in as "..player(id,"usgn").."!")
     else
          parse('hudtxt2 '..id..' 26 "©255000000Not Registered!" 292 363')
          msg2(i,"©255000000You dont have a USGN! Log-in or register!")
     end
end

I thought you was using startround hook for a specific reason IMG:https://backcountrypost.com/forum/addedsmilies/facepalm.gif

Man click here @cs2d lua hook startround
Theres no id parameter. Let me try to explain what a parameter is. Imagine that you want to make a script which says "Player (name) said : (txt)" every time you say something. Then you will use say hook. First catch the id and the text of the player who said something. Then the parameters must be text and id "function _say(id,text)". But you cant do that when the hook is minute. That function with minute hook will be executed every minute, then theres nothing which we can catch.
It would be nice an time parameter but it's stupid
edited 2×, last 31.07.13 12:22:51 pm
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview