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 2184 185 186338 339 Next To the start

old Re: Lua Scripts/Questions/Help

DRoNe
User Off Offline

Quote
Schinken has written
pls explain better.
do you mean when for example:
player 1 kills player 2 -->
player 1 has more kills than player 2 -->
player 1 gets a message?

1
2
3
4
5
6
addhook ("kill","killen")
function killen(id,oper)
if(player(id,"score")>player(opfer,"score")) then
msg2 (id,"your kills are higher than you enemys one");
end
end


yes if player has more kills than all players on server -->
msg("Player name '..kills..'")
edited 2×, last 05.04.10 02:40:51 pm

old Re: Lua Scripts/Questions/Help

Soja1997
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
items = {
               {title ="Medikit",price = 500,cmd = "equip",param=64},
               {title ="Bandage",price = 100,cmd = "equip",param=65},
               {title = "Vodka",price=100,cmd = "shake",param=20000},
               {title = "PrimaryAmmo",price=300,cmd = "equip",param=61},
               {title = "SecondaryAmmo",price=300,cmd = "equip",param=62},
               {title = "Snowball",price=3000,cmd = "equip",param=75},
               {title = "Armor100",price=1000,cmd = "setarmor",param=100},
               {title = "Armor200",price=3000,cmd = "setarmor",param=200},
               {title = "Speed x5",price=1000,cmd = "speedmod",param=25},
               {title = "Speed x10",price=3000,cmd = "speedmod",param=50},
               {title = "MAC10",price=16000,cmd = "equip",param=23}
          }

function createMenu(header, matrix)
     local menuString = header;
     menuString = menuString..", "
     for key, value in ipairs(matrix) do
          menuString = menuString..value.title.." | $"..tostring(value.price).. ","
     end
     return menuString
end


addhook("serveraction","my_serveraction")
function my_serveraction(id,action)
     if(action == 1) then
          menu(id,createMenu("Items",items))
     end
end

addhook("menu","my_menu")
function my_menu(id,title,button)
     if(button == 0) then
          return
     end

     if(title == "Items") then
          if(player(id,"money") > items[button].price) then
               parse("setmoney "..id.." "..(player(id,"money") - items[button].price))
               cmd = string.format("%s %i %i",items[button].cmd,id,items[button].param)
               parse(cmd)
          else
               msg2(id,"©255000000 You have insufficient funds!")
          end
     end
end
Hey can you make next page? only 9 items are located at this page
edited 1×, last 05.04.10 09:54:32 pm

old Re: Lua Scripts/Questions/Help

DRoNe
User Off Offline

Quote
Schinken has written
pls explain better.
do you mean when for example:
player 1 kills player 2 -->
player 1 has more kills than player 2 -->
player 1 gets a message?

1
2
3
4
5
6
addhook ("kill","killen")
function killen(id,oper)
if(player(id,"score")>player(opfer,"score")) then
msg2 (id,"your kills are higher than you enemys one");
end
end


yes if player has more kills than all players on server -->
msg("Player name '..kills..'")

old Plz Make Next Page

Soja1997
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
items = {
               {title ="Medikit",price = 500,cmd = "equip",param=64},
               {title ="Bandage",price = 100,cmd = "equip",param=65},
               {title = "Vodka",price=100,cmd = "shake",param=20000},
               {title = "PrimaryAmmo",price=300,cmd = "equip",param=61},
               {title = "SecondaryAmmo",price=300,cmd = "equip",param=62},
               {title = "Snowball",price=3000,cmd = "equip",param=75},
               {title = "Armor100",price=1000,cmd = "setarmor",param=100},
               {title = "Armor200",price=3000,cmd = "setarmor",param=200},
               {title = "Speed x5",price=1000,cmd = "speedmod",param=25},
               {title = "Speed x10",price=3000,cmd = "speedmod",param=50},
               {title = "MAC10",price=16000,cmd = "equip",param=23}
          }

function createMenu(header, matrix)
     local menuString = header;
     menuString = menuString..", "
     for key, value in ipairs(matrix) do
          menuString = menuString..value.title.." | $"..tostring(value.price).. ","
     end
     return menuString
end


addhook("serveraction","my_serveraction")
function my_serveraction(id,action)
     if(action == 1) then
          menu(id,createMenu("Items",items))
     end
end

addhook("menu","my_menu")
function my_menu(id,title,button)
     if(button == 0) then
          return
     end

     if(title == "Items") then
          if(player(id,"money") > items[button].price) then
               parse("setmoney "..id.." "..(player(id,"money") - items[button].price))
               cmd = string.format("%s %i %i",items[button].cmd,id,items[button].param)
               parse(cmd)
          else
               msg2(id,"©255000000 You have insufficient funds!")
          end
     end
end
Hey can you make next page? only 9 items are located at this page

old Re: Lua Scripts/Questions/Help

siuL
User Off Offline

Quote
Trotskygrad has written
Quick question, how do you find the number of items in a list?

I know there's a command, I just forgot it, >.<

hi trot ( its chunks )
and :
on the console the command is items for gettin item ids
simple put
items
if you have rcon idk lol

old Re: Lua Scripts/Questions/Help

Trotskygrad
User Off Offline

Quote
Khaleed has written
Trotskygrad has written
Quick question, how do you find the number of items in a list?

I know there's a command, I just forgot it, >.<

hi trot ( its chunks )
and :
on the console the command is items for gettin item ids


mmmno...

I mean if you have a table of values,
1
items = {45,56,88}

as given by the playerweapons(id), how do you find now many values are in that table?

old Re: Lua Scripts/Questions/Help

TimeQuesT
User Off Offline

Quote
do you mean:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
health={}
count={}

addhook ("second","sec")
function sec()
for id=1,32 do

if (player(id,"exists")) then
health[id] = player(id,"health");
count[id] = "";
for a = 1,health[id],10 do
count[id] = (""..count[id].."|");
--use count[id] for your life display...
end
end
end
end

old Re: Lua Scripts/Questions/Help

Fehu
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
health={}
count={}

addhook ("second","sec")
function sec()
for id=1,32 do

if (player(id,"exists")) then
health[id] = player(id,"health");
count[id] = "";
for a = 1,health[id],10 do
count[id] = (""..count[id].."|");
--use count[id] for your life display...
end
end
end
end
Sry this dont work
I need hudtxt!! lol ... and one line = 10HP example:

HP: [||||| ] 52/100

old Re: Lua Scripts/Questions/Help

Patasuss
User Off Offline

Quote
Like this: (in use with schinkens code!)
1
parse("hudtxt2 "..id.." "..id.." \""..count[id].."\" 10 220 ")
should work (not tested)

old Re: Lua Scripts/Questions/Help

Fehu
User Off Offline

Quote
Patasuss has written
Like this: (in use with schinkens code!)
1
parse("hudtxt2 "..id.." "..id.." \""..count[id].."\" 10 220 ")
should work (not tested)


Where this write ? ... i really n00b in lua!...

/Edit/

Okay i know

/Edit2/

Why this dont work ?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
health={}
count={}

addhook ("second","sec")
function sec()
	for id=1,32 do

		if (player(id,"exists")) then
			health[id] = player(id,"health");
			count[id] = "";
			for a = 1,health[id],10 do
		count[id] = (""..count[id].."|");	--use count[id] for your life display...
			end
		end
	end
end 

parse("hudtxt2 "..id.." "..id.." \""..count[id].."\" 10 220 ")
To the start Previous 1 2184 185 186338 339 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview