Forum

> > CS2D > Scripts > help me with my lua script
Forums overviewCS2D overview Scripts overviewLog in to reply

English help me with my lua script

20 replies
Page
To the start Previous 1 2 Next To the start

old help me with my lua script

Glix
User Off Offline

Quote
help me with this script this dont work what wrong?
when i press f2 the menu opens all ok. but it don't work.(when i press teleport yellew nothing happens)

THIS IS MY COMPLETE SCRIPT!

Console says
1
LUA ERROR: maps/propnic_happytown_b0.1.0.lua:78: unfinished string near '")'
No work

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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
ddhook("serveraction" , "sa")
function sa(id,action)
     if action==1 then
     menu(id,"Main Menu,Extra Shop|Shop,Teleport|Teleports,Extra|+bonus")
end
end

addhook("menu" , "menu_1")
function menu_1(id, title, button)
     if (title=="Main Menu") then
     if button==1 then
     menu(id,"Extra Shop,Deagle|650$,M3|1700$,AK47|2500$")
end
     if button==2 then
     menu(id,"Teleport,Teleport green|2,000$,Teleport yellow|2,000$")
end
end
     if (title=="Buy weapon") then
     if button==1 then
     if (player(id,"money")>=2000) then
parse("setpos "..id.." 400 2608 ")
parse("setmoney "..id.." "..player(id,"money")-2000)
msg2(id,"©000255000You Teleported for 2,000$ !!!")
else
msg2(id,"©000255000Not enough money !")
end
end
     if button==2 then
     if (player(id,"money")>=2000) then
parse("setpos "..id.." 1904 2064 ")
parse("setmoney "..id.." "..player(id,"money")-2000)
msg2(id,"©000255000You Teleported for 2,000$ !!!")
else
msg2(id,"©000255000Not enough money !")
end
end
     if button==3 then
     if (player(id,"money")>=2500) then
parse("equip "..id.." 30 ")
parse("setmoney "..id.." "..player(id,"money")-2500)
parse("setweapon "..id.." 30 ")
msg2(id,"©000255000You buy a AK-47 for 2500$ !!!")
else
msg2(id,"©000255000Not enough money !")
end
end
end

     if (title=="Extra|+bonus") then
     if button==1 then
     if (player(id,"money")>=300) then
parse("equip "..id.." 64 ")
parse("setmoney "..id.." "..player(id,"money")-300)
msg2(id,"©000255000You buy a Medikit for 300$ !!!")
else
msg2(id,"©000255000Not enough money !")
end
end
     if button==2 then
     if (player(id,"money")>=650) then
parse("equip "..id.." 57 ")
parse("setmoney "..id.." "..player(id,"money")-650)
msg2(id,"©000255000You buy a Kevlar for 650$ !!!")
else
msg2(id,"©000255000Not enough money !")
end
end
end
end

addhook("startround",start.round")
function start.round()
parse('hudtxt2 '..id..' 41 "©000255000Text" 240 5')
end
edited 17×, last 10.05.11 04:50:39 pm

old Re: help me with my lua script

Homam
User Off Offline

Quote
@Yates,
Propnic has written
Console says

1
LUA ERROR: maps/propnic_happytown_b0.1.0.lua:11: attempt to con catenate global 'id' (a nil value)

old Re: help me with my lua script

DannyDeth
User Off Offline

Quote
Because they can be there, and can help readability. They can also do shit like:
1
if not ( id == 3 and player(id,"name") == "LolHai" ) then

old Re: help me with my lua script

Starkkz
Moderator Off Offline

Quote
Did someone look at the first line of the script?, because the parameter "id" is not given. Propnic, if you want any help you may give the complete lua script.

old Re: help me with my lua script

J4x
User Off Offline

Quote
i't not shure but try with this:
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
ddhook("serveraction" , "sa")
function sa(id,action)
	if action==1 then
	menu(id,"Main Menu,Extra Shop|Shop,Teleport|Teleports,Extra|+bonus")
end
end

addhook("menu" , "menu_1")
function menu_1(id, title, button)
	if (title=="Main Menu") then
	if button==1 then
	menu(id,"Extra Shop,Deagle|650$,M3|1700$,AK47|2500$")
end
	if button==2 then
	menu(id,"Teleport,Teleport green|2,000$,Teleport yellow|2,000$")
end
end
	if (title=="Buy weapon") then
	if button==1 then
	if (player(id,"money")>=2000) then
parse("setpos "..id.." 400 2608 ")
parse("setmoney "..id.." "..player(id,"money")-2000)
msg2(id,"©000255000You Teleported for 2,000$ !!!")
else
msg2(id,"©000255000Not enough money !")
end
end
	if button==2 then
	if (player(id,"money")>=2000) then
parse("setpos "..id.." 1904 2064 ")
parse("setmoney "..id.." "..player(id,"money")-2000)
msg2(id,"©000255000You Teleported for 2,000$ !!!")
else
msg2(id,"©000255000Not enough money !")
end
end
	if button==3 then
	if (player(id,"money")>=2500) then
parse("equip "..id.." 30 ")
parse("setmoney "..id.." "..player(id,"money")-2500)
parse("setweapon "..id.." 30 ")
msg2(id,"©000255000You buy a AK-47 for 2500$ !!!")
else
msg2(id,"©000255000Not enough money !")
end
end
end

	if (title=="Extra|+bonus") then
	if button==1 then
	if (player(id,"money")>=300) then
parse("equip "..id.." 64 ")
parse("setmoney "..id.." "..player(id,"money")-300)
msg2(id,"©000255000You buy a Medikit for 300$ !!!")
else
msg2(id,"©000255000Not enough money !")
end
end
	if button==2 then
	if (player(id,"money")>=650) then
parse("equip "..id.." 57 ")
parse("setmoney "..id.." "..player(id,"money")-650)
msg2(id,"©000255000You buy a Kevlar for 650$ !!!")
else
msg2(id,"©000255000Not enough money !")
end
end
end
end

addhook("startround",start.round")
function start.round()
     parse('hudtxt2 '..id..' 41 "©000255000Text" 240 5')
end

old Re: help me with my lua script

Dovahkin
User Off Offline

Quote
Ummm......... i change alot you can just copy or edit it and have fun

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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
addhook("serveraction","sample")
function sample(id,action)
	if action == 1 then
 		menu(id,"Main Menu@b,Extra 

Shop|Shop,Teleport|Teleports,Extra|+bonus")
	end
end

addhook("menu","menucheck")
function menucheck(id,title,sel)
	if title == "Main Menu" then
		if sel == 1 then
			menu(id,"Extra Shop,Deagle|650$,M3|1700$,AK47|2500$")
		end
		if sel == 2 then
			menu(id,"Teleport,Teleport green|2,000$,Teleport 

yellow|2,000$")
		end
	end
end

addhook("menu","wtf")
function wtf(id,title,sel)
	if title == "Extra Shop" then
		if sel == 1 and player(id,"money") >=649 then
			parse("equip "..id.." 3")
			parse("setmoney "..id.." "..player(id,"money")-650)
			msg2(id,"©000255000You've Succesfully bought Deagle!")
		end
		if sel == 2 and player(id,"money") >=1699 then
			parse("equip "..id.." 10")
			parse("setmoney "..id.." "..player(id,"money")-1700)
			msg2(id,"©000255000You've Succesfully bought M3!")
		end
		if sel == 3 and player(id,"money") >=2499 then
			parse("equip "..id.." 30")
			parse("setmoney "..id.." "..player(id,"money")-2500)
			msg2(id,"©000255000You've Succesfully bought Ak-47!")
		end
	end
	if title == "Teleport" then
		if sel == 1 and player(id,"money") >=1999 then
			parse("setpos "..id.." 400 2608 ")
			parse("setmoney "..id.." "..player(id,"money")-2000)
			msg2(id,"©000255000You Teleported for 2,000$ !!!")
		end
		if sel == 3 and player(id,"money") >=1999 then
			parse("setpos "..id.." 200 200 ")
			parse("setmoney "..id.." "..player(id,"money")-2000)
			msg2(id,"©000255000You Teleported for 2,000$ !!!")
		end
	end

-------------------
-- Spawn       --
-------------------
addhook("spawn","lol")
function lol(id)
	parse('hudtxt2 '..id..' 1 "©000255000Text" 240 5')
end
end


Lol?

and the teleporter thing? of course it wont work its out of bounds! 1918 or blah blah blah!

old Re: help me with my lua script

Glix
User Off Offline

Quote
@FN_Linkin Park it says this in console
1
LUA ERROR: maps/propnic_happytown_b0.1.0.lua:78: unfinished string near '")'
edited 1×, last 10.05.11 04:52:47 pm

old Re: help me with my lua script

Homam
User Off Offline

Quote
@FN_Linkin Park, Are you blind? You forgot the A -_-'.

1
ddhook("serveraction" , "sa")

It should be:

1
addhook("serveraction" , "sa")

old Re: help me with my lua script

Yates
Reviewer Off Offline

Quote
Wow, he forgot a letter because he was rushing to help someone. You don't have to do this "-_-" shit on it, just a nice comment would do.

old Re: help me with my lua script

J4x
User 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
addhook("serveraction","sample")
function sample(id,action)
     if action == 1 then
          menu(id,"Main Menu@b,Extra,Shop|Shop,Teleport|Teleports,Extra|+bonus")
     end
end

addhook("menu","menucheck")
function menucheck(id,title,sel)
     if title == "Main Menu" then
          if sel == 1 then
               menu(id,"Extra Shop,Deagle|650$,M3|1700$,AK47|2500$")
          end
          if sel == 2 then
               menu(id,"Teleport,Teleport green|2,000$,Teleport,yellow|2,000$")
          end
     end
end

addhook("menu","wtf")
function wtf(id,title,sel)
     if title == "Extra Shop" then
          if sel == 1 and player(id,"money") >=649 then
               parse("equip "..id.." 3")
               parse("setmoney "..id.." "..player(id,"money")-650)
               msg2(id,"©000255000You've Succesfully bought Deagle!")
          end
          if sel == 2 and player(id,"money") >=1699 then
               parse("equip "..id.." 10")
               parse("setmoney "..id.." "..player(id,"money")-1700)
               msg2(id,"©000255000You've Succesfully bought M3!")
          end
          if sel == 3 and player(id,"money") >=2499 then
               parse("equip "..id.." 30")
               parse("setmoney "..id.." "..player(id,"money")-2500)
               msg2(id,"©000255000You've Succesfully bought Ak-47!")
          end
     end
     if title == "Teleport" then
          if sel == 1 and player(id,"money") >=1999 then
               parse("setpos "..id.." 400 2608 ")
               parse("setmoney "..id.." "..player(id,"money")-2000)
               msg2(id,"©000255000You Teleported for 2,000$ !!!")
          end
          if sel == 3 and player(id,"money") >=1999 then
               parse("setpos "..id.." 200 200 ")
               parse("setmoney "..id.." "..player(id,"money")-2000)
               msg2(id,"©000255000You Teleported for 2,000$ !!!")
          end
     end

-------------------
-- Spawn --
-------------------
addhook("spawn","lol")
function lol(id)
     parse('hudtxt2 '..id..' 1 "©000255000Text" 240 5')
end
end
*Fixed* @Hoamn don't blame for that i didn't wrote that part of the script
To the start Previous 1 2 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview