In this example you can buy and get money by using the use button [default: e].
Lua Script Example
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
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
(function() 	entityID=function(x,y) 		for _,id in pairs(item(0,"table")) do 			if item(id,"x")==x and item(id,"y")==y then 				return id 			end 		end 		return false 	end 	hasWeapon=function(id,weapon) 		for _,wpn in pairs(playerweapons(id)) do 			if weapon==wpn then 				return true 			end 		end 		return false 	end 	_useButton=function(id,x,y) 		weapons={ 				{"AK",2500,30,1,1}, 				{"M4",3100,32,3,1}, 				{"TMP",1250,21,5,1}, 				{"Deagle",650,3,7,1}, 				{"HE",650,51,9,1} 		} 		for _,weapon in pairs(weapons) do 			if entity(x,y,"name")=="buy"..weapon[1] then 				if player(id,"money")>=weapon[2] then 					if entityID(weapon[4],weapon[5]) then 						if hasWeapon(id,weapon[3]) then 							msg2(id,string.char(169).."255000000You already have a "..weapon[1]..".") 							return false 						end 						parse("equip "..id.." "..weapon[3]) 						parse("setweapon "..id.." "..weapon[3]) 						parse("setmoney "..id.." "..player(id,"money")-weapon[2]) 						parse("removeitem "..entityID(weapon[4],weapon[5])) 						msg2(id,string.char(169).."000255000Thank you for purchasing a "..weapon[1]..".") 					else 						msg2(id,string.char(169).."255000000Please wait 10 seconds while the "..weapon[1].." respawns.") 					end 				else 					msg2(id,string.char(169).."255000000You do not have enough money. "..weapon[1].." costs $"..weapon[2]) 				end 			end 		end 		moneys={ 				{"Coins",100,3,9}, 				{"Money",500,5,9}, 				{"Gold",1000,7,9}, 		} 		for _,money in pairs(moneys) do 			if entity(x,y,"name")=="get"..money[1] then 				if entityID(money[3],money[4]) then 					if player(id,"money")==16000 then 						msg2(id,string.char(169).."255000000You can not carry any more money.") 						return false 					end 					parse("setmoney "..id.." "..player(id,"money")+money[2]) 					parse("removeitem "..entityID(money[3],money[4])) 					msg2(id,string.char(169).."000255000You received $"..money[2]..".") 				else 					msg2(id,string.char(169).."255000000Please wait 10 seconds while the "..money[1].." respawns.") 				end 			end 		end 	end 	addhook("usebutton","_useButton") 	return false end)()
How to
To insert lua into a map:
Create 2 entities (Trigger_Start, Trigger_IF)
Give a name for Trigger_IF
Set trigger for Trigger_Start to the name of Trigger_IF
Put your lua around these tags
Go to this website
Paste your script in the first text field
Click remove line breaks
Copy the output into the condition box of the if trigger
There you have it, placing lua within maps. Hopefully DC will add an entity called ENV_Lua where you can place insert lua without the wrappers.
Create 2 entities (Trigger_Start, Trigger_IF)
Give a name for Trigger_IF
Set trigger for Trigger_Start to the name of Trigger_IF
Put your lua around these tags
1
2
3
4
5
6
7
2
3
4
5
6
7
(function() --place your lua here 	return false end)()
Go to this website
Paste your script in the first text field
Click remove line breaks
Copy the output into the condition box of the if trigger
There you have it, placing lua within maps. Hopefully DC will add an entity called ENV_Lua where you can place insert lua without the wrappers.
A youtube video of this example is located here.
Approved by Seekay
Download
2 kb, 583 Downloads