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 2253 254 255338 339 Next To the start

old Re: Lua Scripts/Questions/Help

Evool
User Off Offline

Quote
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

old Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Quote
@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.

old Re: Lua Scripts/Questions/Help

murilog
User Off Offline

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


Your Cash : 4000 but is infinity

and to give money Example :

!givemoney <id> thx

old Re: Lua Scripts/Questions/Help

archmage
User Off Offline

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

old Re: Lua Scripts/Questions/Help

CJ7
BANNED Off Offline

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

old Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Quote
Dark Byte has written
@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.

old Re: Lua Scripts/Questions/Help

3RROR
User Off Offline

Quote
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])

old Re: Lua Scripts/Questions/Help

RAVENOUS
BANNED Off Offline

Quote
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.
edited 1×, last 09.09.10 12:58:40 am

old Re: Lua Scripts/Questions/Help

murilo12
User Off Offline

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


Your Cash : 4000 but is infinity

and to give money Example :

!givemoney <id> thx

old Re: Lua Scripts/Questions/Help

KaTiL
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
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 !?

old Re: Lua Scripts/Questions/Help

CeLiL_CaN
User Off Offline

Quote
@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
edited 1×, last 09.09.10 09:28:30 am

old Re: Lua Scripts/Questions/Help

HaRe
User Off Offline

Quote
CeLiL_CaN has written
@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.

old Re: Lua Scripts/Questions/Help

RAVENOUS
BANNED Off Offline

Quote
Dark Byte has written
@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

old Re: Lua Scripts/Questions/Help

Cure Pikachu
User Off Offline

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

old Re: Lua Scripts/Questions/Help

RAVENOUS
BANNED Off Offline

Quote
Pikachu xD has written
@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
edited 1×, last 09.09.10 12:29:27 pm

old Re: Lua Scripts/Questions/Help

HaRe
User Off Offline

Quote
Pikachu xD has written
@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
To the start Previous 1 2253 254 255338 339 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview