Forum

> > CS2D > Scripts > Login Message
Forums overviewCS2D overview Scripts overviewLog in to reply

English Login Message

6 replies
To the start Previous 1 Next To the start

old Login Message

Marcell
Super User Off Offline

Quote
Whats wrong with my code?
(I think everything is bad..)

Logged in with my 6943 usgn id(user)
Then i get nothing when i join to server.

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
----------------------------------------
--**  RolePlay lua by TheAnonymous  **--
----------------------------------------


-------------------
---  HOOKS  -------
-------------------

addhook("join","usgn_auth")


-------------------
---  ADMINS  ------
-------------------
usgn = {
r8 = {6943}; -- AdminController(s)
r7 = {};		-- SuperAdmin(s)
r5 = {};		-- Admin 5 
r4 = {};		-- Admin 4
r3 = {};		-- Admin 3
r2 = {};		-- Admin 2
r1 = {};		-- Admin 1
rh = {};		-- Admin Helper(s)
};

function usgn_auth(id,usgn,msg)
	if player(usgn) <=r8 then
		msg("[Superadmin] "..player(id,"name").." just logged in.")
	else 
	return 0;
	end
end

Error:
LUA ERROR: sys/lua/admins.lua:28: bad argument #1 to 'player' (number expected, got nil)


Please help to fix it, i just learn lua scripting

old Re: Login Message

EngiN33R
Moderator Off Offline

Quote
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
----------------------------------------
--**  RolePlay lua by TheAnonymous  **--
----------------------------------------


-------------------
---  HOOKS  -------
-------------------

addhook("join","usgn_auth")


-------------------
---  ADMINS  ------
-------------------
usgn = {
r8 = {6943}; -- AdminController(s)
r7 = {};          -- SuperAdmin(s)
r5 = {};          -- Admin 5 
r4 = {};          -- Admin 4
r3 = {};          -- Admin 3
r2 = {};          -- Admin 2
r1 = {};          -- Admin 1
rh = {};          -- Admin Helper(s)
}

function table.contains(table, element)
	for key, value in pairs(table) do
		if value == element then
			return true
		end
	end
end

function usgn_auth(id)
     if table.contains(usgn.r8,player(id,"usgn")) then
          msg("[Superadmin] "..player(id,"name").." just logged in.")
     end
end

Try this.
edited 1×, last 12.10.13 11:35:44 am

old Re: Login Message

Marcell
Super User Off Offline

Quote
With your one got this error:

LUA ERROR: sys/lua/admins.lua:28: bad argument #1 to 'pairs' (table expected, got nil)

old Re: Login Message

Marcell
Super User Off Offline

Quote
user EngiN33R has written
Sorry, edited. Try it now.


Thanks so much, working now.

+1 Virtual rep



Now i got out of ideas why isn't work this hudtxt script.
It has no error in console..
Hudimg works well, this just a part of script

1
2
3
4
5
6
7
8
9
function hudimg()
     local id=image("gfx/roleplay/infobar.png",320,460,2)
	 imagecolor(id,0,255,0)
	 imageblend(id,1)
end

function hudtext(id,txt,usgn,x,y)
	parse('hudtxt2 '..id..' 1 "©000000000USGNID:" '..player(id,"usgn")..' 8 440 ')
end
edited 2×, last 12.10.13 01:05:12 pm

old Re: Login Message

Avo
User Off Offline

Quote
You just put double quotation mark in the wrong place.
Code >
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview