Forum

> > CS2D > Scripts > Lua Scripts/Questions/Help
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Lua Scripts/Questions/Help

6.770 Antworten
Seite
Zum Anfang Vorherige 1 2252 253 254338 339 Nächste Zum Anfang

alt Re: Lua Scripts/Questions/Help

head600
BANNED Off Offline

Zitieren
HaRe hat geschrieben
head600 hat geschrieben
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...

alt Re: Lua Scripts/Questions/Help

murilog
User Off Offline

Zitieren
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

alt Re: Lua Scripts/Questions/Help

HaRe
User Off Offline

Zitieren
@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')

alt Re: Lua Scripts/Questions/Help

Heartless Soldier
User Off Offline

Zitieren
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!

alt Re: Lua Scripts/Questions/Help

head600
BANNED Off Offline

Zitieren
HaRe hat geschrieben
@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

alt Re: Lua Scripts/Questions/Help

murilog
User Off Offline

Zitieren
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

alt Re: Lua Scripts/Questions/Help

FASTDIE
User Off Offline

Zitieren
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

alt Re: Lua Scripts/Questions/Help

Sudden Death
User Off Offline

Zitieren
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

alt Re: Lua Scripts/Questions/Help

FASTDIE
User Off Offline

Zitieren
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

alt Re: Lua Scripts/Questions/Help

murilog
User Off Offline

Zitieren
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

alt Re: Lua Scripts/Questions/Help

mafia_man
User Off Offline

Zitieren
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

alt Re: Lua Scripts/Questions/Help

archmage
User Off Offline

Zitieren
murilog hat geschrieben
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

alt Re: Lua Scripts/Questions/Help

archmage
User Off Offline

Zitieren
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.
Mehr >
1× editiert, zuletzt 06.09.10 23:10:50

alt Re: Lua Scripts/Questions/Help

Mawd
User Off Offline

Zitieren
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.

alt Re: Lua Scripts/Questions/Help

CJ7
BANNED Off Offline

Zitieren
Dark Byte hat geschrieben
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"))
Zum Anfang Vorherige 1 2252 253 254338 339 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht