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 2252 253 254338 339 Next To the start

old Re: Lua Scripts/Questions/Help

head600
BANNED Off Offline

Quote
HaRe has written
head600 has written
function initArray(m)
local array = {}
for i = 1, m do
array[i]=0
end
return array
end

yemek1=initArray(32)
yemek=initArray(32)

addhook("minute","asd")
function asd(id)
yemek1[id]=yemek1[id]+10
yemek[id]=yemek[id]+10
parse('hudtxt2 '..id..' 4 "Susuzluk: '..yemek1[id]..'" 0 155')
parse('hudtxt2 '..id..' 4 "Aclik: '..yemek[id]..'" 0 150')
end
                         

addhook("spawn","dsa")
function dsa(id)
parse('hudtxt2 '..id..' 4 "Susuzluk: '..yemek1[id]..'" 0 155')
parse('hudtxt2 '..id..' 4 "Aclik: '..yemek[id]..'" 0 150')
end


whats wrong??


1
2
3
4
5
6
7
8
9
10
11
addhook("minute","asd")
function asd(id)
	for id = 1,32 do
		if (player(id,"exists")) then
			yemek1[id]=yemek1[id]+10
			yemek[id]=yemek[id]+10
			parse('hudtxt2 '..id..' 4 "Susuzluk: '..yemek1[id]..'" 0 155')
			parse('hudtxt2 '..id..' 4 "Aclik: '..yemek[id]..'" 0 150')
		end
	end
end



this is work but i see only one

normal :
aclik : 0
susuzluk : 0

but i see only aclik : 0

pls test this...

old Re: Lua Scripts/Questions/Help

murilog
User Off Offline

Quote
hi all i want one script like this : cts say !infoct <id> , and player go to jail and spawn on jail , if txt !free <id> the player is free thx , the jail Y : 100 X :100

old Re: Lua Scripts/Questions/Help

HaRe
User Off Offline

Quote
@head600:

change

1
2
parse('hudtxt2 '..id..' 4 "Susuzluk: '..yemek1[id]..'" 0 155')
               parse('hudtxt2 '..id..' 4 "Aclik: '..yemek[id]..'" 0 150')

to
1
2
parse('hudtxt2 '..id..' 4 "Susuzluk: '..yemek1[id]..'" 0 155')
               parse('hudtxt2 '..id..' 5 "Aclik: '..yemek[id]..'" 0 150')

old Re: Lua Scripts/Questions/Help

Heartless Soldier
User Off Offline

Quote
When I use images in lua, then when I join the server from a remote PC It only transfer 1 images (of 5).
Ive tried putting the images in a map so that they transfer completly but it didn't work (images appear in another possition or with black background).

Halp me!

old Re: Lua Scripts/Questions/Help

head600
BANNED Off Offline

Quote
HaRe has written
@head600:

change

1
2
parse('hudtxt2 '..id..' 4 "Susuzluk: '..yemek1[id]..'" 0 155')
               parse('hudtxt2 '..id..' 4 "Aclik: '..yemek[id]..'" 0 150')

to
1
2
parse('hudtxt2 '..id..' 4 "Susuzluk: '..yemek1[id]..'" 0 155')
               parse('hudtxt2 '..id..' 5 "Aclik: '..yemek[id]..'" 0 150')



thank you

old Re: Lua Scripts/Questions/Help

murilog
User Off Offline

Quote
hi all i want one script like this : cts say !infoct <id> , and player go to jail and spawn on jail , if txt !free <id> the player is free thx , the jail Y : 100 X :100

old Re: Lua Scripts/Questions/Help

FASTDIE
User Off Offline

Quote
its works but i want buy only one gun, but do not want that occured bug of many guns in one slot sorry for my bad english
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
addhook("usebutton","shop")
function shop(id,x,y)

cash = player(id,"money")

	if (x==9) and (y==4) then
		if cash>2999 then
		msg2(id,"You Have Bought AK-47")
		parse("setmoney "..id.." "..cash-3000)
		parse("equip "..id.." 30")

		else

		msg2(id,"You Haven't Enough Money@C")
	end
end
end

old Re: Lua Scripts/Questions/Help

Sudden Death
User Off Offline

Quote
who can make for me mod:
players class : Commander| Special Weapons| Medic| Tech| (i think i can mapke it on clas.lua but its dont my problem :P) adn when player trigger button (and its position or name : |?) adn player class = tech then trigger once (once trigger deadly) and player see message "you hacking panel" but when player class is not Tech then player what trigger this see message "You aren't Tech, You can't hack it!" Who can help me ; d

old Re: Lua Scripts/Questions/Help

FASTDIE
User Off Offline

Quote
hey i tried to do this alone... but its not working help me...
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
addhook("usebutton","shop")
function shop(id,x,y)

cash = player(id,"money")
weapon = player(id,"itemtype")

	if (x==9) and (y==4) then
		if cash>2999 then
			if (weapon>=61 and weapon<=68) then
			msg2(id,"You Have Bought AK-47")
			parse("setmoney "..id.." "..cash-3000)
			parse("equip "..id.." 30")

			else
	
			msg2(id,"You Haven't Enough Money@C")

			end

			else

			msg2(id,"You Can't Carry More Items@C")
	end
end
end

old Re: Lua Scripts/Questions/Help

murilog
User Off Offline

Quote
hi all i want one script like this : cts say !arrest <id> , and player go to jail and spawn on jail , if txt !leavejail <id> the player is free thx , the jail Y : 100 X :100

old Re: Lua Scripts/Questions/Help

mafia_man
User Off Offline

Quote
MSEK i see a script wheres but i write for you new one :
1
2
3
4
5
6
7
8
addhook( "objectdamage", "objdmg")
function objdmg( id, dmg)
	if dmg < 0 then
		if id == 9 then
			return 1
		end
	end
end

old Re: Lua Scripts/Questions/Help

archmage
User Off Offline

Quote
murilog has written
hi all i want one script like this : cts say !arrest <id> , and player go to jail and spawn on jail , if txt !leavejail <id> the player is free thx , the jail Y : 100 X :100


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
addhook("say", "say_", 0)
player_pos = {}

for i = 1, 32 do
	table.insert(player_pos, {0,0})
end

function say_(id,txt)
	if ( txt:sub(1,7) == "!arrest" ) then
		player_pos[tonumber(txt:sub(8))] = {player(tonumber(txt:sub(8)), "x"), player(tonumber(txt:sub(8)),'y')}
		parse("setpos "..txt:sub(8).." 100 100")
		return 1
	elseif ( txt:sub(1,10) == "!leavejail" ) then
		parse("setpos "..txt:sub(12).." "..player_pos[tonumber(txt:sub(8))][1].." "..player_pos[tonumber(txt:sub(8))][2])
		return 1
	end
end

old Re: Lua Scripts/Questions/Help

archmage
User Off Offline

Quote
Oh sorry no.
Here.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
addhook("say", "say_", 0)
player_pos = {}

for i = 1, 32 do
     table.insert(player_pos, {0,0})
end

function say_(id,txt)
	if ( player(id, "team") == 2 ) then
    	 if ( txt:sub(1,7) == "!arrest" ) then
        	  player_pos[tonumber(txt:sub(8))] = {player(tonumber(txt:sub(8)), "x"), player(tonumber(txt:sub(8)),'y')}
       	   parse("setpos "..txt:sub(8).." 100 100")
         	 return 1
     	elseif ( txt:sub(1,10) == "!leavejail" ) then
      	    parse("setpos "..txt:sub(12).." "..player_pos[tonumber(txt:sub(8))][1].." "..player_pos[tonumber(txt:sub(8))][2])
         	 return 1
	end
     end
end

Edit
I am trying to transpose from the examples at cplusplus.com to Lua. The one I want is the one that represents a string in binary.
More >
edited 1×, last 06.09.10 11:10:50 pm

old Re: Lua Scripts/Questions/Help

Mawd
User Off Offline

Quote
Can you guys help me on, Jumping/Crouching?
Jumping:
a player stand in front of an obstacle, when he pressed spacebar he will be teleported over the obstacle.
Crouching:
a guy stand in front of a sprite(which is a Wall), when he press Ctrl, he will crouch and crawl under it.

old Re: Lua Scripts/Questions/Help

CJ7
BANNED Off Offline

Quote
Dark Byte has written
I would like it in bits.
http://www.cplusplus.com/files/convert.zip
That is what I am trying to transpose to Lua.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
function num_to_bits(n)
	local num = tonumber(n)
	local l = math.floor(math.log(n)/math.log(2))
	str = ''

	for i=l,0,-1 do
		local coef = math.pow(2,i)

		if coef <= num then
			num = num - coef
			str = str..'1'
		else
			str = str..'0'
		end
	end
	return str
end

print(num_to_bits("5"))
To the start Previous 1 2252 253 254338 339 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview