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 2253 254 255338 339 Nächste Zum Anfang

alt Re: Lua Scripts/Questions/Help

Evool
User Off Offline

Zitieren
Hi, please help me
I have often asked question: How make button, which on first used - off, and second used - on?

Very sorry for my bad english

alt Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Zitieren
@DarkByte

The following will transpose between base10 and any arbitrary bases (including 2)

1
2
3
4
5
6
7
8
function base10toN(x,n)
	local digits = {}; n = n or 2
	for i=math.floor(math.log(x)/math.log(n)), 0, -1 do
          		table.insert(digits, math.floor(x/math.pow(n, i)))
          		x=x%math.pow(n,i)
     	end
     	return digits
end

n defaults to 2, you can also use the cyclic properties of this pseudo-group to generate nonunique combinations of an arbitrary number of bins.

alt Re: Lua Scripts/Questions/Help

murilog
User Off Offline

Zitieren
hi all , i again , can make script of money , Example :


Your Cash : 4000 but is infinity

and to give money Example :

!givemoney <id> thx

alt Re: Lua Scripts/Questions/Help

archmage
User Off Offline

Zitieren
@CJ7, Lee
I don't want to convert numbers ('sides Lee gave me code for that already). I want to convert strings into their binary representation.
Ex:
hello -> 11010001100101110110011011001101111

alt Re: Lua Scripts/Questions/Help

CJ7
BANNED Off Offline

Zitieren
@Dark Byte

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

function ascii_to_bits(s)
	buf = ''
	for i=1, string.len(s) do
		buf = buf..num_to_bits(string.byte(s,i))
	end
	return buf
end

print(ascii_to_bits('hello'))

alt Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Zitieren
Dark Byte hat geschrieben
@CJ7, Lee
I don't want to convert numbers ('sides Lee gave me code for that already). I want to convert strings into their binary representation.
Ex:
hello -> 11010001100101110110011011001101111


Assume that you have the function base10ToN:

1
2
bin = ""
for i=1,#str do local a = table.concat(base10ToN(str:byte(i)),""); bin = bin ..  string.rep("0",8-#a)..a end

You can partition the final string bin into its components by taking it apart by substrings of len 8. Note that without padding the binary into parts of 8, there can exist no algorithm to reverse the binary representation back into pure string.

alt Re: Lua Scripts/Questions/Help

3RROR
User Off Offline

Zitieren
Need help in tibia. Why it appears this?

[23:27:43] LUA ERROR: sys/lua/cs2dtibia/monsters.lua:237: bad argument #2 to 'random' (interval is empty)

1
tilex, tiley = math.random(m.spawn1[1], m.spawn2[1]), math.random(m.spawn1[2], m.spawn2[2])

alt Re: Lua Scripts/Questions/Help

RAVENOUS
BANNED Off Offline

Zitieren
Got a problem with this code, I don't understand why:

1
2
3
4
5
6
7
addhook("projectile","pro_hook")

function pro_hook(id,weapon)
	if weapon==4 then
          parse("strip "..id.." 4")
	end
end

In fact I just want that he's loosing the P228 after shooting once with it.
1× editiert, zuletzt 09.09.10 00:58:40

alt Re: Lua Scripts/Questions/Help

murilo12
User Off Offline

Zitieren
hi all , i again , can make script of money , Example :


Your Cash : 4000 but is infinity

and to give money Example :

!givemoney <id> thx

alt Re: Lua Scripts/Questions/Help

KaTiL
User Off Offline

Zitieren
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
-------------------------------------------
----------Script made by SuppLy------------
-------------------------------------------

function rp_msg(clr,txt)
	msg([[©]]..clr..[[]]..txt)
end

function rp_msg2(id,clr,txt)
	msg2(id,[[©]]..clr..[[]]..txt)
end


-- CT Item 

addhook("say","spawn") 
function spawn(id,txt) 
	if(txt=="!rp_item") then
        if (player(id,"team") == 2) then
          parse("equip "..id.." 1")
          parse("equip "..id.." 3")
          parse("equip "..id.." 6")
          parse("equip "..id.." 32")
          parse("equip "..id.." 41")
          parse("equip "..id.." 45")
          parse("equip "..id.." 46")
          parse("equip "..id.." 47")
          parse("equip "..id.." 56")
          parse("equip "..id.." 59")
          parse("equip "..id.." 69")
          parse("equip "..id.." 78")
          parse("equip "..id.." 83")
          parse("equip "..id.." 88") 
        else
          rp_msg2(id,[[255000000]],[[CT'ye özel komut! ]])
          parse("kill "..id.." died")
          end 
	end
end

-- Car Nice

addhook("spawn","spawn2")
addhook("say","spawn2") 
function spawn2(id,txt) 
	if(txt=="!rp_car") then
        if (player(id,"team") == 2) then 
	  parse("speedmod "..id.." 30")
          freeimage(id) 
          id1=image("gfx/policecar.bmp",1,1,200+id) 
          imagescale(id1,1,1) 
          imageblend(id1,3) 
          imagealpha(id1,1.0)
          imagecolor(id1,255,255,255)  
         else
          rp_msg2(id,[[255000000]],[[CT'ye özel komut! ]])
          parse("kill "..id.." died")       
          end 
	end
end

-- Restart

addhook("spawn","spawn3")
addhook("say","spawn3") 
function spawn3(id,txt) 
	if(txt=="!rp_restart") then
        if (player(id,"team") == 2) then 
	  parse("restart 1")
         else
          rp_msg2(id,[[255000000]],[[CT'ye özel komut! ]])
          parse("kill "..id.." died")       
          end 
	end
end

-- Speed

addhook("spawn","spawn4")
addhook("say","spawn4") 
function spawn4(id,txt) 
	if(txt=="!rp_speed") then
        if (player(id,"team") == 2) then 
	  parse("speedmod "..id.." 35")  
         else
          rp_msg2(id,[[255000000]],[[CT'ye özel komut! ]])
          parse("kill "..id.." died")       
          end 
	end
end

-- Hackmenu

addhook("spawn","spawn5")
addhook("say","spawn5") 
function spawn5(id,txt) 
	if(txt=="!hackmenu") then
	  parse("kick "..id.." You are a hacker!")    
	end
end

-- Advertising

addhook("minute","saying")
function saying()
	msg([[000255000]],[[Komutlar için !help yaziniz. @C]])
end

-- Say !help
addhook("say","help")
function help(id,txt)
	if(txt=="!help") then
	rp_msg([[000255000]],[[Komutlar: ]])
	rp_msg([[000255000]],[[!rp_item -- CT'ye özel... ]])
	rp_msg([[000255000]],[[!rp_car -- CT'ye özel... ]])
	rp_msg([[000255000]],[[!rp_restart -- CT'ye özel... ]])
	rp_msg([[000255000]],[[!rp_speed -- CT'ye özel... ]])
        rp_msg([[000255000]],[[!hackmenu -- T 'lere özel... ]])
	end
end

Hi all... Hackmenu(Spawn5) is not working. Help me !?

alt Re: Lua Scripts/Questions/Help

CeLiL_CaN
User Off Offline

Zitieren
@KaTiL:

Change hack menu :
1
2
3
4
5
6
7
8
9
10
-- Hackmenu

addhook("spawn","spawn5")
addhook("say","spawn5")
function spawn5(id,txt)
     if(txt=="!hackmenu") then
      parse("kick "..id.."")
      msg2(id,"You are Hacker!")
     end
end
Not test
1× editiert, zuletzt 09.09.10 09:28:30

alt Re: Lua Scripts/Questions/Help

HaRe
User Off Offline

Zitieren
CeLiL_CaN hat geschrieben
@KaTiL:

Change hack menu :
1
2
3
4
5
6
7
8
9
10
-- Hackmenu

addhook("spawn","spawn5")
addhook("say","spawn5")
function spawn5(id,txt)
     if(txt=="!hackmenu") then
      parse("kick "..id.."")
      msg2(id,"You are Hacker!")
     end
end


Fail

change

1
parse("kick "..id.."")

to

1
parse("kick "..id)

/edit

@Katil:
btw , Your script fails totaly, I have no time to fix ur script. To many damn errors in it.

alt Re: Lua Scripts/Questions/Help

RAVENOUS
BANNED Off Offline

Zitieren
Dark Byte hat geschrieben
@skipper use the attack hook instead


attack hook is somehow not better..

1
2
3
4
5
6
7
addhook("attack","att_hook")

function att_hook(id)
	if weapon==4 then
          parse("strip "..id.." 4")
	end
end

alt Re: Lua Scripts/Questions/Help

Cure Pikachu
User Off Offline

Zitieren
@Skipper
You missed out something
1
2
3
4
5
6
addhook("attack","att_hook")
function att_hook(id,weapon)
	if weapon==4 then
		parse("strip "..id.." 4")
	end
end

alt Re: Lua Scripts/Questions/Help

RAVENOUS
BANNED Off Offline

Zitieren
Pikachu xD hat geschrieben
@Skipper
You missed out something
1
2
3
4
5
6
addhook("attack","att_hook")
function att_hook(id,weapon)
	if weapon==4 then
		parse("strip "..id.." 4")
	end
end


That's the same. It's still not working.

LUA ERROR: Attempt to call a nil value.

I hate those errors. I'm just a beginner
1× editiert, zuletzt 09.09.10 12:29:27

alt Re: Lua Scripts/Questions/Help

HaRe
User Off Offline

Zitieren
Pikachu xD hat geschrieben
@Skipper
You missed out something
1
2
3
4
5
6
addhook("attack","att_hook")
function att_hook(id,weapon)
	if weapon==4 then
		parse("strip "..id.." 4")
	end
end


fail

weapon dosent exists in attack hook

1
2
3
4
5
6
addhook("attack","att_hook")
function att_hook(id)
	if (player(id,"weapontype") == 4) then
		parse("strip "..id.." 4")
	end
end
Zum Anfang Vorherige 1 2253 254 255338 339 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht