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 297 98 99338 339 Nächste Zum Anfang

alt Re: Lua Scripts/Questions/Help

Yorty
User Off Offline

Zitieren
leegao hat geschrieben
@yorty
1
2
3
4
function mw2spawn(id) 
     wpnp = primw[id] 
     return wpnp
end

I use that, and

function famas(id)
     primw=39
end

I spawn, and get LUA ERROR: attempt to call a nil value

Im terrible at this.

alt Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Zitieren
Zitat
LUA ERROR: attempt to call a nil value


Can you give me a list of all function calls that you're making?

alt Re: Lua Scripts/Questions/Help

Yorty
User Off Offline

Zitieren
leegao hat geschrieben
Zitat
LUA ERROR: attempt to call a nil value


Can you give me a list of all function calls that you're making?


Dont know what you mean exactly but...

addhook("menu","mw2menu5")
function mw2menu5(id,title,key)
     sc = player(id,"score")
     if (title=="Select Your Rifle") then
     if (key == 1) then     
          famas(id)
     end
(Not end)

function famas(id)
     primw=39
end

function mw2spawn(id)
wpnp = primw[id]
return wpnp
end

alt Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Zitieren
1
2
3
4
5
6
7
8
9
10
11
12
13
14
players = {}

wpnids = {39, } -- add in the rest of your weapons

addhook("menu","mw2menu5") 
function mw2menu5(id,title,key) 
	if (title=="Select Your Rifle") then
		players[id] = wpnids[key]
	end
end

function mw2spawn(id)
	return  players[id]
end

It's a good idea to plan out the program beforehand to minimize development woes. Especially important is the underlying architecture of the script.

alt Re: Lua Scripts/Questions/Help

Yorty
User Off Offline

Zitieren
leegao hat geschrieben
players = {}

wpnids = {39, } -- add in the rest of your weapons

addhook("menu","mw2menu5")
function mw2menu5(id,title,key)
     if (title=="Select Your Rifle") then
          players[id] = wpnids[key]
     end
end

function mw2spawn(id)
     return players[id]
end

I know, I know.
Though what you posted wouldn't work well cus I got rank requirements for weapons...

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
40
41
addhook("menu","mw2menu5")
function mw2menu5(id,title,key)
	sc = player(id,"score")
	if (title=="Select Your Rifle") then
	if (key == 1) then	
		famas(id)
	end

	if (key == 2) then
	if (sc > 22) then	
		galil(id)
	else msg2(id,"©000000255Your rank is too low.@C")
	end
end
	if (key == 3) then
	if (sc > 99) then	
		m4a1(id)
	else msg2(id,"©000000255Your rank is too low.@C")
	end
end
	if (key == 4) then
	if (sc > 124) then	
		sg552(id)
	else msg2(id,"©000000255Your rank is too low.@C")
	end
end
	if (key == 5) then
	if (sc > 299) then	
		aug(id)
	else msg2(id,"©000000255Your rank is too low.@C")
	end
end
	if (key == 6) then
	if (sc > 390) then	
		ak47(id)
	else msg2(id,"©000000255Your rank is too low.@C")
	end
end

	end
end


It's a good idea to plan out the program beforehand to minimize development woes. Especially important is the underlying architecture of the script.

alt Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Zitieren
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
--require("sys.lua.wpnids")
players = {}

wpnids = {(famas, 0), (galil, 22), (m4a1, 99), (sg552, 124), (aug, 299), (ak47, 390) } -- add in the rest of your weapons

addhook("menu","mw2menu5") 
function mw2menu5(id,title,key) 
	local score = player(id, "score") -- score here indicates kills..., not sure 390 kills for an AK is prudent
	if (title=="Select Your Rifle") then
		if score > wpnids[key][2] then
			players[id] = wpnids[key][1]
		end
	end
end

function mw2spawn(id)
	return  players[id]
end

you can either use KO's wpnids.lua file or replace the variable names with their respective wpnids.

alt Re: Lua Scripts/Questions/Help

Yorty
User Off Offline

Zitieren
leegao hat geschrieben
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
--require("sys.lua.wpnids")
players = {}

wpnids = {(famas, 0), (galil, 22), (m4a1, 99), (sg552, 124), (aug, 299), (ak47, 390) } -- add in the rest of your weapons

addhook("menu","mw2menu5") 
function mw2menu5(id,title,key) 
	local score = player(id, "score") -- score here indicates kills..., not sure 390 kills for an AK is prudent
	if (title=="Select Your Rifle") then
		if score > wpnids[key][2] then
			players[id] = wpnids[key][1]
		end
	end
end

function mw2spawn(id)
	return  players[id]
end

you can either use KO's wpnids.lua file or replace the variable names with their respective wpnids.

Thanks, can I get direct link to it? Reason I got ak is that it requires rank 17 in-game, ive balanced all wpns with mp_wpndmg...

Now I'm getting ')' expected near ','

Now I COULD send you the whole script, but I doubt you would wanna go through it. Though if you would I could accredit you.
Its really messed up.

alt Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Zitieren
sorry about that, should've been

wpnids = {{famas, 0}, {galil, 22}, {m4a1, 99}, {sg552, 124}, {aug, 299}, {ak47, 390} }

You'll have to replace the literal variables with their wpnids unless you are incorporating Kiffer Opa's wpnids.lua file

alt Re: Lua Scripts/Questions/Help

Yorty
User Off Offline

Zitieren
leegao hat geschrieben
sorry about that, should've been

wpnids = {{famas, 0}, {galil, 22}, {m4a1, 99}, {sg552, 124}, {aug, 299}, {ak47, 390} }

You'll have to replace the literal variables with their wpnids unless you are incorporating Kiffer Opa's wpnids.lua file

thanks.

Edit: Can set names to numbers, get errors. Know where I can get his script? All uploads were reset. Do you have it?
1× editiert, zuletzt 22.11.09 06:24:04

alt Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Zitieren
I procedurally generated mine, otherwise you can just replace the variable names with the numbers (famas with 39 etc), I just placed them there as examples.

alt Re: Lua Scripts/Questions/Help

Yorty
User Off Offline

Zitieren
leegao hat geschrieben
I procedurally generated mine, otherwise you can just replace the variable names with the numbers (famas with 39 etc), I just placed them there as examples.

Cant, tried replacing with 39, cant be a number.
Btw, could you be nice enough to add in the error message too? Ah cant.

alt Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Zitieren
wpnids = {{39, 0}, {38, 22}, {32, 99}, {31, 124}, {33, 299}, {30, 390}}

I'm not getting any errors at all.

alt Re: Lua Scripts/Questions/Help

NozliW
User Off Offline

Zitieren
is it possible to assign a key to do multiple functions when joining a server?
functions like:
1. choose a weapon
2. fire that weapon
3. change to last weapon
Is it possible ?
EDIT:
is it possible to trigger a lua menu with a trigger_use,trigger_move or etc ?

alt Re: Lua Scripts/Questions/Help

Yorty
User Off Offline

Zitieren
leegao hat geschrieben
wpnids = {{39, 0}, {38, 22}, {32, 99}, {31, 124}, {33, 299}, {30, 390}}

I'm not getting any errors at all.

When I spawn its the nil value thing

alt Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Zitieren
Yorty hat geschrieben
When I spawn its the nil value thing

CS2D have strange problem with function nils.
Sometimes when you add, removing hooks, you have to restart CS2d.
And of course check names of nil valuables for match.

alt Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Zitieren
I assumed you had handled that earlier in the script, if you want to have default weapon, just add in the following

1
2
3
4
function mw2spawn(id) 
	if not players[id] then players[id] = wpnids[1][1] end
	return players[id] 
end

alt Re: Lua Scripts/Questions/Help

Starkkz
Moderator Off Offline

Zitieren
hi, i was making a mod, and i need help.

Spoiler >


i like make the bombard menu, only at score 400 to up.
but it work only on 400, not work up of 400.
what is the problem?
Zum Anfang Vorherige 1 297 98 99338 339 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht