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 297 98 99338 339 Next To the start

old Re: Lua Scripts/Questions/Help

Yorty
User Off Offline

Quote
leegao has written
@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.

old Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Quote
Quote
LUA ERROR: attempt to call a nil value


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

old Re: Lua Scripts/Questions/Help

Yorty
User Off Offline

Quote
leegao has written
Quote
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

old Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Quote
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.

old Re: Lua Scripts/Questions/Help

Yorty
User Off Offline

Quote
leegao has written
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.

old Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Quote
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.

old Re: Lua Scripts/Questions/Help

Yorty
User Off Offline

Quote
leegao has written
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.

old Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Quote
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

old Re: Lua Scripts/Questions/Help

Yorty
User Off Offline

Quote
leegao has written
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?
edited 1×, last 22.11.09 06:24:04 am

old Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Quote
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.

old Re: Lua Scripts/Questions/Help

Yorty
User Off Offline

Quote
leegao has written
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.

old Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

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

I'm not getting any errors at all.

old Re: Lua Scripts/Questions/Help

NozliW
User Off Offline

Quote
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 ?

old Re: Lua Scripts/Questions/Help

Yorty
User Off Offline

Quote
leegao has written
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

old Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Quote
Yorty has written
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.

old Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Quote
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

old Re: Lua Scripts/Questions/Help

Starkkz
Moderator Off Offline

Quote
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?
To the start Previous 1 297 98 99338 339 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview