Forum

> > CS2D > Scripts > Lua Scripts/Questions/Help
Forums overviewCS2D overview Scripts overviewLog in to reply

English Lua Scripts/Questions/Help

6,770 replies
Page
To the start Previous 1 2146 147 148338 339 Next To the start

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
When you join T it prints your usgn twice because you have instructed your script to do so.
Maybe tabbing your code will save you from some headache.
Here I tabbed it for you:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
ADMIN={}
ADMIN.SuperAdmins={1,2}--Just for example

addhook("team","Team")
function Team(p,team)
	for index, value in ipairs(ADMIN.SuperAdmins) do
		if team == 1 then
			if player(p,"usgn") == value then
				return 0
			else
				return 1
			end
		end
	end
end
Your problem is that you return 1 if the first item in the table isn't equal to your USGN, returning cuts the execution of a function.
So you might want to move the return 1 right before the last end. This way it will only return 1 if the USGN hasn't been found in your table after your loop.

old Re: Lua Scripts/Questions/Help

Homer
User Off Offline

Quote
Yea, The script is working, but here's the thing, its not that it's printing value's twice, it's that it's printing different value's based on my team that confuses me.
Eh, nevermind, I fixed it I missed something... Didn't show you the entire script apparetnly
Thanks flacko, The return value also helped

old Re: Lua Scripts/Questions/Help

Homer
User Off Offline

Quote
I suppose you could make your own version of standard? But, I think you can't, I don't know for sure, that's a DC question.

old Re: Lua Scripts/Questions/Help

BrunoRZ
User Off Offline

Quote
Here I am once again

addhook("use","weaponshopentry")
function weaponshopentry(id,event,data,x,y)
           if (event==100) then
           if (x==91) and (y==40) then
            parse("setname "..id.." Medic")
      end
     end


~~~~~What is wrong this time? ~~~~~~~~~
I want the guy press a button, then gets another name (Medic)

old Re: Lua Scripts/Questions/Help

BrunoRZ
User Off Offline

Quote
TheKilledDeath has written
end missing @ the end



addhook("use","weaponshopentry")
function weaponshopentry(id,event,data,x,y)
if (event==100) then
if (x==91) and (y==40) then
parse("setname "..id.." Medic")
end
end
end


------------------------ Still not working

old Re: Lua Scripts/Questions/Help

LV
BANNED Off Offline

Quote
@BrunoRZ
.
WORKS!
.
You forgot put the if (event==100) inside lol

.
1
2
3
4
5
6
7
8
addhook("use","weaponshopentry")
function weaponshopentry(id,event,data,x,y)
if (x==91) and (y==40) then
if (event==100) then
parse("setname "..id.." Medic")
end
end
end
edited 2×, last 25.01.10 06:31:00 pm

old Re: Lua Scripts/Questions/Help

Redefinder
User Off Offline

Quote
Mod-_er_- has written
how to make a small menu?

1
2
3
4
addhook("menu",smallmenu")
function smallmenu(id)
menu(id,"[b]Put stuff you like here[/b]") --Must be separated with comma
[b]<--Put other stuff here[/b]

old Re: Lua Scripts/Questions/Help

memo
COMMUNITY BANNED Off Offline

Quote
this F**** massage keep coming i mean WITH OUT A STOP on console what that mean ... I hate this nil thing


1
LUA ERROE:attempt to call a nil value

i try hard to fix this but i canot i even try to see the Lua manual , but its have a hard English words for me (I am Arabic).

i think the mistake is here :-
Spoiler >

old Re: Lua Scripts/Questions/Help

Homer
User Off Offline

Quote
Umm, Look for an undeclared variable or a variable or table that doesn't match in that big hulk of a script, Yea, Try and find it, is it just showing up at the beginning?

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote

Ok memo, I'm coming from my pool and as soon as I've seen your post, I felt like I wanted to kill somebody.
But I'll try to control that.

We have discussed what does nil mean, what does that error mean, and how to solve problems regarding nil, but I think we didn't discuss how to use the search button. Maybe because you might find needless stuff that waste your time.
So you can better search by yourself on the previous pages of this thread.

Thank you.

old Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Quote
The following variables

dh4.classes.classmenu(id)
level(id)

are not declared. Please check to make sure that these are actually declared.

old Re: Lua Scripts/Questions/Help

memo
COMMUNITY BANNED Off Offline

Quote
@Leegao
yes that's the problem thanks you .

@flacko
Sorry this is my first program language so its hard on me

old Re: Lua Scripts/Questions/Help

Homer
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
addhook("projectile","FlareTele")
function FlareTele(id,weapon,x,y)
if (player(id,"usgn") == 38115) then
if (weapon == 54) then
parse ("setpos "..id..""..x..""..y.."")
print(""..x.." "..y.."")
print(""..w.."")
print(""..id.."")
end
end
end
I've tryed to find out what the heck is wrong with this thing, but it still gives me nil values, I've checked the info.txt and I'm using the right tags.. I just don't really know what's wrong.. So can someone help me with this. Since, I can't figure out what's nil.

old Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Quote
@Homer,

1st, better don't use "" (empty strings)
So instead print(""..id.."") write this:
1
print(id)
2nd, You should add spaces in setpos parsing.
1
parse("setpos "..id.." "..x.." "..y)
print(""..w.."") -- w is nil valuable.

I don't see more nil conditions in your function.

memo has written
Hmmm.. How to make a table value for E.g (test.classes.classmenu) ??

1
test.classes.classmenu = {}
To the start Previous 1 2146 147 148338 339 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview