Forum

> > CS2D > Scripts > Lua Scripts/Questions/Help
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Lua Scripts/Questions/Help

6.770 Antworten
Seite
Zum Anfang Vorherige 1 2133 134 135338 339 Nächste Zum Anfang

alt Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Zitieren
1
2
3
4
5
6
7
8
9
10
11
your_usgn = 0 --Here you put your usgn account
team_u_wanna_join = 0 --Here you put the team you want to be able to join

addhook("team","homer_team")
function homer_team(p,team)
	if team == team_u_wanna_join then --If this player wants to join your team
		if player(p,"usgn") ~= your_usgn then --check if it's using ur usgn
			return 1 --if not, we don't change the team
		end
	end
end

alt Re: Lua Scripts/Questions/Help

Homer
User Off Offline

Zitieren
Eh, thanks Alright, So why isn't there an else return 0, but could I use elif usgn == my_usgn then it doesn't do it. Thus, my confusion. Oh, I see, the look thing isn't a calling method, it's a built in passive thingy(Sorry, but I don't know what else to call anything). Thanks and it works flacko.

Alright, Sorry if im a nuisance, but, what is the beginning initailizing of the array for. Like this.
function initArray(m)
     local array = {}
     for i = 1, m do
          array[i]=0
     end
     return array
end
Is it used for tables? or something?

alt Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Zitieren
Usually a table looks like that:
1
table = {0,0,0,0,0,0,0,0,0,0,0}
Instead of that we can use this function:
1
2
3
4
5
6
7
8
9
[spoiler]function initArray(m)
	local array = {}
	for i = 1, m do
		array[i]=0
	end
	return array
end[/spoiler]

table = initArray(10)

alt Please help.

KINGGOLDrus
User Off Offline

Zitieren
1
2
3
4
5
6
7
8
9
10
11
12
356. if (rpg_item_type[pl_inv1[id]]==2) then
357. 	pl_inv[id]=pl_inv[id]','..tostring(pl_inv1[id])..
358.	i[id]=i[id]+1
		if (i[id]==9) then
			i[id]=i[id]+1
			pl_inv[id]=pl_inv[id]',Next >>'
		end
		if (i[id]==18) then
			i[id]=i[id]+1
			pl_inv[id]=pl_inv2[id]',Back <<'
		end
end
ERROR: unexpected symbol near "="
1
358.	i[id]=i[id]+1
Please, help me! I'm enmeshed in code.

alt Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Zitieren
1
pl_inv[id]=pl_inv[id]',[b]'..tostring(pl_inv1[id])..[/b]
Wrong string concatenation...
Probably it should look like this:
1
pl_inv[id]=pl_inv[id]..","..pl_inv1[id]

There shouldn't be any problems about strings in this case.

alt Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Zitieren
@BLACK, I already said what nil means. (three times)

Valuable is equal nil when it's not existing.

Blazzingxx hat geschrieben
Nope, nil valuable means value doesn't exist.
It means you haven't declared your value.

Like (Nil Comparing Example):
1
2
3
4
5
6
7
8
9
if (value == nil) then -- Check If Value [b]Doesn't[/b] Exist
	print("Value Doesn't Exist")
end

value = 5 -- Value Is Now equal 5

if (value ~= nil) then -- Check Value If It's [b]Does[/b] Exist
	print("Value Exist! and equal "..value)
end

alt Re: Lua Scripts/Questions/Help

KimKat
GAME BANNED Off Offline

Zitieren
mat5b hat geschrieben
I'm doing a cool teamwork script called the (CAN) AllyMod.
Many brand new gameplay features come with it, like trading, teamworking, and many more!
Here's a small screen of the progress:
http://i50.tinypic.com/15dm7lz.png
That reminds me of Medal of Honor: Allied Assault, you could perhaps even add icons from MoH: AA using lua image instead of hudtxt. I'd love to see MoH: AA 2D.

In example...
Spoiler >
1× editiert, zuletzt 09.01.10 14:44:13

alt Re: Lua Scripts/Questions/Help

Homer
User Off Offline

Zitieren
Eh, I hate to ask this of you, but could you show me how to use a table, like an example, cause I get what tables do, but I don't know how to apply them.

alt Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Zitieren
1
2
3
4
5
your_table = {"Cool","Bad","Good"} -- Table

for i = 1, #your_table do -- Loop
	print(your_table[i].." = your_table["..i.."]")
end

It's going to print out:
1
2
3
Cool = your_table[1]
Bad = your_table[2]
Good = your_table[3]

alt Re: Lua Scripts/Questions/Help

Homer
User Off Offline

Zitieren
Oh so like a table is like an array in C++ or whatever, it looks like an array that I know from somewhere else, Thanks. Now, not to annoy you at all, how do you record text, like to see what a person says, like for example if a person says
!say 5555
it would type 5555.
How do you record a persons input.
And thanks for the help blazzing.

alt Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Zitieren
There is many ways how to make that.
In all case we have to use say hook text parameter.

It's the way by using sub.string function. Try "!say hey hey hey"
1
2
3
4
5
6
7
addhook("say","say_func") -- Adding Hook

function say_func(p,t) 
	if (string.sub(t, 1, 4) == "!say") then -- Checking If First 4 Letters Equal "!say"
		msg(player(p,"name").." says: "..string.sub(t, 5, #t)) -- Shows All Text After "!say "
	end
end

alt Re: Lua Scripts/Questions/Help

YellowBanana
BANNED Off Offline

Zitieren
Table isn't the same as a c++ array.
A c++ array can hold hold the same primitive types.
A Lua table can hold strings integers and other tables. Lua tables probably work with pointers.

alt Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Zitieren
1
2
3
4
5
6
7
8
addhook("second", "heal")
function heal()
	for i = 1 , 32, 1 do
		if player(i,"exists") then
			parse("sethealth "..i.." "..player(i, "health")+3)
		end
	end
end

alt Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Zitieren
YellowBanana hat geschrieben
Table isn't the same as a c++ array.
A c++ array can hold hold the same primitive types.
A Lua table can hold strings integers and other tables. Lua tables probably work with pointers.


no, Lua doesn't have pointer driven tables as Lua uses dynamic memory management, which not only defeats the purpose of pointers, but also renders it unusable as &pointer = &pointer + 1 in Lua would give you a completely arbitrary memory location (which could even be just a part of another data type), therefore Lua omits pointers altogether.

alt Re: Lua Scripts/Questions/Help

memo
COMMUNITY BANNED Off Offline

Zitieren
need help with this script its D-H new mod but i have this bug with the credits so any one know how to fix it ...

Spoiler >


need help here !
1× editiert, zuletzt 09.01.10 21:54:34

alt Re: Lua Scripts/Questions/Help

Homer
User Off Offline

Zitieren
Thanks yellow, and blazzing, Sorry, but I have another question xD, Im curious about what the string.sub(t,1,4) does. Like what is it's function really. And why are the arguments t,1,4? Thanks for all your help

alt Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Zitieren
Yea, that's some comparing.
1
2
3
4
t = "Word"
string.sub(t, 1, 1) = "W"
string.sub(t, 2, 2)  = "o"
string.sub(t, 3, 4)  = "rd"
Zum Anfang Vorherige 1 2133 134 135338 339 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht