So heres things i wanted to happen,everytime a player kills someone he gain +1 gold/Problem: it doesn't even show the hudtxt and i cant gain gold.2nd one-the !help and !buy commands i put in doesn't do anything,if a players says !buy then it will open up an menu of items(though i still haven't finished it),and if the player says !help then it would list commands(like !buy),Its not working though ,i didnt get any error messages.Help please.
Forum
CS2D Scripts Why my script not working?Why my script not working?
19 replies 1
So heres things i wanted to happen,everytime a player kills someone he gain +1 gold/Problem: it doesn't even show the hudtxt and i cant gain gold.2nd one-the !help and !buy commands i put in doesn't do anything,if a players says !buy then it will open up an menu of items(though i still haven't finished it),and if the player says !help then it would list commands(like !buy),Its not working though ,i didnt get any error messages.Help please.
1
player(id,"exist")
Change your hudtxt2(id) to
1
parse('hudtxt2 '..id..' 49 "©255215Gold: '..gold[id]..'"540 348 0')
edited 1×, last 30.01.15 01:19:46 pm
i'll try to fix it as soon as possible.
edit:
maybe it's will be not wrong(edited full code):
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
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
function array(m,v) local a = {} for i = 1, m do a[i] = v end return a end gold = array(32,0) addhook("kill","kills") function kills(id) gold[id]=gold[id]+1 end addhook("ms100","Gold") function Gold(id) for _,id in pairs (player(0, "table")) do parse('hudtxt2 '..id..' 0 "\169255195100Gold: '..gold[id]..' " 400 308') 	 end end addhook("say","help") function help(id,txt) 	if txt=="!help" then parse("sv_msg2 "..id.." say !buy to buy items at the cost of gold") return 1 	elseif txt=="!buy" then menu(id,"Special Items,Supply Drop|Cost-2,Airstrike|Cost-5,Bombing Run|Cost-8") return 1 	end end addhook("menu","buyM1") function buyM1(id,title,button) if title == "Special Items" then if button == 1 then parse("equip "..id.." 76") end end end
edited 1×, last 30.01.15 01:16:05 pm
Use this instead:
1
parse('hudtxt2 '..id..' 0 "'string.char(169)..'169255195100Gold: '..gold[id]..' " 400 308')
1
\169colorrgp
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
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
--Variables function initArray(m) 	local array = {} 	for i = 1, m do 		array[i]=0 	end 	return array end gold=initArray(32) --Script addhook("kill","kills") function kills(id) 	gold[id]=gold[id]+1 end addhook("ms100","Gold") function Gold() 	for _,id in pairs(player(0,'table')) do 		parse('hudtxt2 "..id.." 49 ©255215Gold: "..gold[id].." 540 348') 	end end addhook("say","help") function help(,txt) 	if (txt=="!help") then 		parse("sv_msg2 "..id.." say !buy to buy items at the cost of gold") 	end 	if (txt=="!buy") then 		menu("..id..","Special Items,Supply Drop|Cost-2,Airstrike|Cost-5,Bombing Run|Cost-8") 	end 	return 1 end addhook("menu","buyM1") function buyM1(id,title,button) 	if title == "Special Items" then 		if button == 1 then 			parse("equip "..id.." 76") 		end 	end end
try to use it
Mora has written
@ Bowlinghead: or (color rgb is ur color you're wanna for. ex 255250199 will \160255250199)
1
\169colorrgp
Thanks for this advice :3.
Mora has written
maybe so? idk, may be wrong.
i'll try to fix it as soon as possible.
edit:
maybe it's will be not wrong(edited full code):
I haven't made menu buy s**t, i think you can do by yourself..
i'll try to fix it as soon as possible.
edit:
maybe it's will be not wrong(edited full code):
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
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
function array(m,v) local a = {} for i = 1, m do a[i] = v end return a end gold = array(32,0) addhook("kill","kills") function kills(id) gold[id]=gold[id]+1 end addhook("ms100","Gold") function Gold(id) for _,id in pairs (player(0, "table")) do parse('hudtxt2 '..id..' 0 "\169255195100Gold: '..gold[id]..' " 400 308') 	 end end addhook("say","help") function help(id,txt) 	if txt=="!help" then parse("sv_msg2 "..id.." say !buy to buy items at the cost of gold") return 1 	elseif txt=="!buy" then menu(id,"Special Items,Supply Drop|Cost-2,Airstrike|Cost-5,Bombing Run|Cost-8") return 1 	end end addhook("menu","buyM1") function buyM1(id,title,button) if title == "Special Items" then if button == 1 then parse("equip "..id.." 76") end end end
Thx all for the replies,but its still not working
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
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
gold = {} for id = 1, 32 do 	gold[id] = 0 end for none, hook in pairs({"kill", "always", "say", "menu"}) do 	addhook(hook, hook .. "hook") end function killhook(killer) 	gold[killer] = gold[killer] + 1 end function alwayshook() 	for none, id in pairs(player(0, "tableliving")) do 		parse("hudtxt2 " .. id .. " 49 \"\169255215000Gold: " .. gold[id] .. "\" 540 348") 	end end function sayhook(id, text) 	if (text == "!help") then 		msg2(id, "Say \"!buy\" to buy special items which costs gold!") 	elseif (text == "!buy") then 		menu(id, "Special Items,Supply Drop|2 Golds,Airstrike|5 Golds,Bombing Run|8 Golds") 		 		return 1 	end end function menuhook(id, title, button) 	if (title == "Special Items") then 		if (button == 1) then 			parse("equip " .. id .. " 76") 		end 	end end
1
Lua: Adding function 'functionname' to hook 'hookname'
EDIT: @ Dousea It works,thx dude though i'm still wondering on why my script didnt work.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2
3
4
5
6
7
8
9
10
11
12
13
14
15
function menuhook(id, title, button) if (title == "Special Items") then --Airstrike if (button == 2) and gold[id]>5 then parse("equip " .. id .. " 76") gold[id] = gold[id] - 5 elseif (button == 2) and gold[id]<5 then msg2(id,"Not enough Gold") elseif (button == 1) and gold[id]>2 then --Supply Drop timer(5000,"parse","equip 61 " ..x.. " " ..y) gold[id] = gold[id] - 2 elseif (button == 1) and gold[id]<2 then msg2(id,"Not enough Gold") end end end
EDIT: Wtf for some reason that problem doesn't happen if i use it on a Dedicated server.
edited 1×, last 31.01.15 11:48:04 am
If you use ">=" it means it has to be equal or higher.
So for button 2 you need at least 6 gold!
And at line 9 you wrote x and y. Are the defined?
Work:
This ammo spawn on the position where you have used it!
Ex your pos is x3 and y7 you will press "buy shit ammo" and walk away, after 5 sec this item will spawn at x3 and y7, but not at your new position.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
addhook("menu","menuhook") function menuhook(id, title, button, tilex, tiley) if (title == "Special Items") then if button == 1 then --airstrike 			if gold[id]>=5 then parse("equip " .. id .. " 76") gold[id] = gold[id] - 5 else msg2(id,"Not enough money, idiot!") end elseif button == 2 then if gold[id]>=2 then --Supply Drop timer(5000,"parse","spawnitem 61 "..player(id,"tilex").." "..player(id,"tiley")) gold[id] = gold[id] - 2 			else msg2(id,"Not enough money, idiot!") 			end 		end 	end end
edited 4×, last 31.01.15 01:38:45 pm
1
2
3
4
5
6
2
3
4
5
6
function alwayshook() for none, id in pairs(player(0, "tableliving")) do parse("hudtxt2 " .. id .. " 48 \"\169255215000Gold: " .. gold[id] .. "\" 540 348") parse("hudtxt2 " .. id .. " 49 \"\169255215000Level: " ..Levels[id].. " 540 400") end end
1
2
2
parse("hudtxt2 " .. id .. " 49 \"\169255215000Level: " ..Levels[id].. " 540 400") -- wrong parse("hudtxt2 " .. id .. " 49 \"\169215000Level: " .. Levels[id] .. "\" 540 400") -- right
1