Forum

> > CS2D > Scripts > Display USGN ID / Equip bots on spawn
Forums overviewCS2D overview Scripts overviewLog in to reply

English Display USGN ID / Equip bots on spawn

19 replies
To the start Previous 1 Next To the start

old Display USGN ID / Equip bots on spawn

Ace Howl
User Off Offline

Quote
Hello.
Based on old title... but new problem.
1. How to make non registered player... (hard to say, here's a picture)IMG:https://i.imgur.com/OwmB5vP.png

As you can see, unregistered player have '0' value (the yellow text) then I want to make it into red text. So this is what I did:
1
2
3
4
5
function spawniii(id)
	if player(id,"usgn")==0 then
		parse("hudtxt2 "..id.." 0 \"©255000000USGN: Not registered \" 0 430 0")
	end
end
The result is same as the yellow one.

2. How to make bots equip defined weapon?
1
2
3
4
5
6
7
addhook("spawn","spawnbot")
function spawnbot(id)
	if player(id,"bot") then
		parse("equip "..id.." XX")
		parse("equip "..id.." XX")
	end
end
This doesn't work as user EngiN33R stated from my previous forum.

That's it for now...

old Re: Display USGN ID / Equip bots on spawn

DC
Admin Off Offline

Quote
Those thread titles you are using are pointless. Nobody will ever know what your threads are actually about... I fixed your title. Please choose better titles in future or I may simply delete your threads.

1: I don't get your question. The code you provided should display the red text for users who are not logged in. What else do you want? Do you want to log out users? Of course you can't do that (and it makes no sense to do it).

2: Take a look at the referene. Do NOT use equip in the spawn hook. NEVER. Use the return value instead.
cs2d lua hook spawn
Your code translated to the correct form is:
1
2
3
4
5
6
addhook("spawn","spawnbot")
function spawnbot(id)
     if player(id,"bot") then
          return "XX,XX"
     end
end
With XX being weapon type IDs you want to equip. It's even shorter this way
Note that return ends the function so if you want to do more stuff insert it BEFORE the return command.
edited 2×, last 05.12.13 01:09:02 pm

old Oh no...

Ace Howl
User Off Offline

Quote
Sorry, i'm a dumbass . Thanks for the reminder anyway.
For the 1, unlike registered A, A's screen will appear hudtxt2 "USGN: XXXXXX". But B is different ( B is unregistered). So, B's screen will appear hudtxt2 "USGN: Not registered"

old Re: Display USGN ID / Equip bots on spawn

sheeL
User Off Offline

Quote
1
2
3
4
5
6
7
function spawniii(id)
     if player(id,"usgn")==0 then
		parse("hudtxt2 "..id.." 0 \"©255000000USGN: Not registered \" 0 430 0");
	else
		parse("hudtxt2 "..id.." 0 \"©255000000USGN: "..player(id,"usgn").."\" 0 430 0");
     end
end

old Re: Display USGN ID / Equip bots on spawn

Ace Howl
User Off Offline

Quote
Ok, I will explain more calmfully . First, A (not registered) enter my server. After A spawn, the hudtxt2 appears to A's screen with text "USGN: 0". My request is, could you change the hud into "USGN: Not registered".

old Re: Display USGN ID / Equip bots on spawn

sheeL
User Off Offline

Quote
See this example @user Ace Howl:

1
2
3
4
5
6
7
8
9
10
11
addhook("join","_join")
function _join(param)
     if player(param,"usgn") > 0 then
          parse("hudtxt2 "..param.." 0 \"©000255000USGN: "..player(param,"usgn").."\" 0 430 0");
     else
           parse("hudtxt2 "..param.." 0 \"©255000000USGN: Not registered \" 0 430 0");
     end
end

-- "..player(param,"usgn").." == Player's USGN // ex : 45813
-- You can change it // ex : You are logged in USGN

old 1 of 2 solved

Ace Howl
User Off Offline

Quote
Good. It works. Speaking of the bots, I did what user DC did but still doesn't work . I'm confused with that.

old Re: Display USGN ID / Equip bots on spawn

sheeL
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
addhook("spawn","spawnbot")
function spawnbot(id)
     if player(id,"bot") then
          return "XX,XX" -- Change here for the Weapon id
     end
end

-- XX,XX = WEAPON ID, WEAPON ID
-- Ex : 32,45

old Same problem

Ace Howl
User Off Offline

Quote
I did it but always same result.
This what I did:
1
2
3
4
5
6
7
addhook("spawn","bot_spawn")

function bot_spawn(id)
	if player(id,"bot") then
		return "30,51"
	end
end
still same problem. I guess my CS2D is broken or something.

old True

Ace Howl
User Off Offline

Quote
Yes, I have been using multiple of same hook which is more than 1 hook.
addhook("spawn","spawni")
addhook("spawn","spawnii")
addhook("menu","menui")
addhook("menu","menuii")
addhook("hit","hiti")
addhook("hit","hitii")
addhook("hit","hitiii")
addhook("attack","attacki")
addhook("attack","attackii")


And could you describe me how priority works and what happened to the functions? Also give me an example of hook and function. I don't realize there has a priority.

old Re: Display USGN ID / Equip bots on spawn

DC
Admin Off Offline

Quote
Read the description at cs2d lua cmd addhook. It tells you everything you need to know.
In short: The function hooked with the highest priority will be executed LAST.
Also the game will take the return value of the function hooked with the highest priority (as there is no way to handle multiple return values properly).

old Re: Display USGN ID / Equip bots on spawn

Ace Howl
User Off Offline

Quote
If that so, are the codes that I'm doing are right? (the code is for example)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
addhook("spawn","spawni",1)
addhook("spawn","spawnii",2)
addhook("spawn","spawniii",3)

function spawni(id)
	return "xx,xx"
	end
end

function spawnii(id)
	msg("Example")
end

function spawniii(id)
	if player(id,"team")==1 then
		menu(id,"a,b,c")
	elseif player(id,"team")==2 then
		menu(id,"d,e,f")
	end
end
P/S: I know nothing about priority so this maybe gives you a headache

old Re: Display USGN ID / Equip bots on spawn

DC
Admin Off Offline

Quote
No, this is wrong. Read and think again.

× spawni is the only function actually returning something so it must have the HIGHEST priority - you gave it the lowest. Higher value = higher priority.

(p.s.: You are still having xx there. I hope you know that this must be replaced with actual weapon type IDs otherwise it is not going to work.)
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview