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 2267 268 269338 339 Next To the start

old a little help plz

Boss
User Off Offline

Quote
im trying to get this work but each time i do it i lose the menu.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
s_bike_b = [[]]
function udp_sbike(id)
	if pl_have_bike[id]==1 then
		s_bike_b = [[Return the Motorcycle]]
	elseif pl_have_bike[id]==0 then
		s_bike_b = [[Rent a Motorcycle]]
	end
end

s_car_b = [[]]
function udp_scar(id)
	if pl_have_car[id]==1 then
		s_car_b = [[Return the Car]]
	elseif pl_have_car[id]==0 then
		s_car_b = [[Rent a car]]
	end
end

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
elseif sel == 8 then
			menu(id,[[Rent List@b,Rent a Motorcycle,Rent a car]])
		end
	end
	if men == [[Rent List]] then
		if sel == 1 then
			if pl_have_bike[id]==0 then
				bike_img_pos[id]=image([[gfx/[TB]Reality Roleplay Project/Add-Ons/Vehicles/motorcycle-copy.png]],1,1,1)
				imagepos(bike_img_pos[id],player(id,[[x]]),player(id,[[y]]),player(id,[[rot]]))
				vehicle_tx[id]=player(id,[[tilex]])
				vehicle_ty[id]=player(id,[[tiley]])
				vehicle_x[id]=player(id,[[x]])
				vehicle_y[id]=player(id,[[y]])
				pl_have_bike[id]=1
			elseif sel == 2 then
			if pl_have_bike[id]==0 then
				bike_img_pos[id]=image([[gfx/[TB]Reality Roleplay Project/Add-Ons/Vehicles/motorcycle-copy.png]],1,1,1)
				imagepos(bike_img_pos[id],player(id,[[x]]),player(id,[[y]]),player(id,[[rot]]))
				vehicle_tx[id]=player(id,[[tilex]])
				vehicle_ty[id]=player(id,[[tiley]])
				vehicle_x[id]=player(id,[[x]])
				vehicle_y[id]=player(id,[[y]])
				pl_have_bike[id]=1
			elseif pl_have_bike[id]==1 then
				if pic[id]>0 then
					parse([[customkill ]]..id..[[ Eject ]]..id)
					parse([[explosion ]]..vehicle_x[id]..[[ ]]..vehicle_y[id]..[[ 100 200 ]]..id)
					vehicle_tx[id]=0
					vehicle_ty[id]=0
					vehicle_x[id]=0
					vehicle_y[id]=0
					freeimage(bike_img[id])
				else
					parse([[explosion ]]..vehicle_x[id]..[[ ]]..vehicle_y[id]..[[ 100 200 ]]..id)
					vehicle_tx[id]=0
					vehicle_ty[id]=0
					vehicle_x[id]=0
					vehicle_y[id]=0
					freeimage(bike_img_pos[id])
				end
				pl_have_bike[id]=0
			end
		end
	end

old Function Question

sixpack
User Off Offline

Quote
Okay!
I got a question for ya!
Are there any LUA commands to make the script wait?
I mean:

msg("HELLO!")
wait 1000 --waits 1000ms
msg("MY NAME IS SCRIPT!")

[Random examples given!]

old Re: Lua Scripts/Questions/Help

DC
Admin Off Offline

Quote
no because it would make the whole game wait = huge lag. not a good idea

you have to work with the built-in timer system which is pretty easy. read sys/lua/info.txt in your cs2d folder.

your sample done the right way:
1
2
3
4
5
6
msg("HELLO!")
timer(1000,"timer_msg","MY NAME IS SCRIPT!")

function timer_msg(txt)
	msg(txt)
end
(untested)

old Re: Lua Scripts/Questions/Help

Casper-
User Off Offline

Quote
i am just wondering but i get error like
"LUA ERROR: maps/zm_nacht_der_untoten_v1.3.lua:72: unexpected symbol near 'then' "

i think its this
1
local c=math.random(1,13)==1 then
cuz i think i cant get more than 10 do i ?

P.S. i was just testing will it work over 10

old Re: Lua Scripts/Questions/Help

HaRe
User Off Offline

Quote
DaKnOb has written
Okay!
I got a question for ya!
Are there any LUA commands to make the script wait?
I mean:

msg("HELLO!")
wait 1000 --waits 1000ms
msg("MY NAME IS SCRIPT!")

[Random examples given!]


you can always do this

1
2
3
4
5
6
7
8
9
10
11
12
13
14
timer = 9999999
howlong = 1000 -- How long there should be between that shit

addhook("ms100","timer") function timer()
	timer=timer+1
	if timer==howlong then
		msg("MY NAME IS SCRIPT!")
	end
end

addhook("minute","startit") function startit()
	msg("HELLO!")
	timer=0
end

@Burex explain more on the script and btw use

local c = math.random(1, 13)
if c==5 then

and yes it works more than 10

old Re: Lua Scripts/Questions/Help

HaRe
User Off Offline

Quote
shuft has written
Is there how like if some 1 move on X,Y tile and get a menu ?


1
2
3
4
5
6
addhook("movetile","ifmove") function ifmove(id,x,y)
-- x and y = tile x and y
	if x==x and y==y then
		menu(id,"Whatever,lol")
	end
end

old Re: Lua Scripts/Questions/Help

Jynxxx
User Off Offline

Quote
Can anyone make me a script.
That gives people speedmod on the kills they get.
But if they die they go back down to 0 speedmod like they have to kill in a row like unstopable the get 6 speedmod.

old Re: Lua Scripts/Questions/Help

HaRe
User Off Offline

Quote
Dantes Inferno has written
Can anyone make me a script.
That gives people speedmod on the kills they get.
But if they die they go back down to 0 speedmod like they have to kill in a row like unstopable the get 6 speedmod.


1
2
3
4
5
6
7
addhook("kill","speedget") function speedget(id)
	parse("speedmod "..id.." "..(player(id,"speedmod") + 1))
end

addhook("die","speedre") function speedre(id)
	parse("speedmod "..id.." 0")
end

old Re: Lua Scripts/Questions/Help

Jynxxx
User Off Offline

Quote
Hey i have a question, I put the utsfx mod(in the samples

folder) on my server but i want it to end up in the middle of

the screen and it doesn' t even show all the levels of the

kills it only shows sheds first blood and doublekill.

Can someone make me a new one
edited 1×, last 29.09.10 12:08:14 am

old Re: Lua Scripts/Questions/Help

TDShuft
User Off Offline

Quote
Spoiler >

help ??

old Re: Lua Scripts/Questions/Help

MasterAsp
User Off Offline

Quote
Spoiler >

old hey guys i need a little help plz

Boss
User Off Offline

Quote
my gm is roleplay so if anyone know something about it plz help me out with this little thing

i think its a bug from the game because i did everything correct im a scripter i study script i use c++, scripting at lua its easy but the commands different if someone know where i can find the commands for lua reply.

here the script:

first i add the license at menu

1
menu(id,[[Drop System,$100,$500,$1000,$5000,$10000,$50000,$100000,Vehicle Shop,license Shop,]])

second i add the other menu for licence shop

1
2
elseif sel == 9 then
			menu(id,[[Rent a license@b,Building License(50k),Vehicle License(50k),]])

third i add the commands for license shop

1
2
3
4
5
6
7
8
9
10
if men == [[Rent a license]] then
		if sel == 1 then
		  if rp_license[pl]==false then
			 rp_license[pl]=true
			 rp_msg2([[000255000]],[[License Shop Owner Rent you a Building license!]])
		    end
				else
				rp_msg2([[000255000]],[[You Dont Have Money To Rent This license!]])
			end
		end

evrything works fine but the license menu didnt open but i see it at the first menu, second menu didnt show up anyone know why?

thx for help

old Re: Lua Scripts/Questions/Help

GreenDevil
User Off Offline

Quote
Please reply fast!!! :S
Something is wrong!
1
2
3
4
5
6
7
8
9
10
11
local money = 100


addhook("movetile","monzer")
function monzer(id,money)
	if (""..player(id,"tilex").." and "..player(id,"tiley")"") then
	tilex = 53
		tiley = 40
	parse("setmoney "..id.." "..(player(id,"money")+1)"")
	end
end
edited 1×, last 29.09.10 04:34:17 pm

old Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Quote
@MeGaEdIIToRMaN,
Your script makes no sense, in other words everything is wrong.
At least, tell me what that function should do...
1
2
3
4
addhook("movetile","monzer")
function monzer(id)
	parse("setmoney "..id.." "..(player(id,"money")+1))
end

old Re: Lua Scripts/Questions/Help

HaRe
User Off Offline

Quote
GrandMyth has written
@MeGaEdIIToRMaN,
Your script makes no sense, in other words everything is wrong.
At least, tell me what that function should do...
1
2
3
4
addhook("movetile","monzer")
function monzer(id)
	parse("setmoney "..id.." "..(player(id,"money")+1))
end


he wants this

1
2
3
4
5
6
addhook("movetile","monzer")
function monzer(id,x,y)
	if x==53 and y==40 then
		parse("setmoney "..id.." "..(player(id,"money")+1))
	end
end

old help? :'D

Coffe
User Off Offline

Quote
I was creating new items for my server of tibia, When i click on "dedicate server" and when the program runs, the console give me two Errors, i was wondering if someone could tell me the mistakes that i made.

1)First One

Lua : adding funcion 'TIMERms100' to hook 'ms100'
LUA ERROR : sys/lua/cs2dtibia/items.lua:1467: unespected symbol near ' . '

Spoiler >


2)Second One

ERROR: failed to load 'bot/names.txt'

Thanks a lot if you answer my question
edited 1×, last 29.09.10 07:04:50 pm

old no comment

Boss
User Off Offline

Quote
ok this is the last post for me here i post 2 and no one answer anw i fix them. so this one is very easy the problem with end.




if i do it like this :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
if men == [[T Menu]] then
		if sel == 1 then
			menu(id,[[T Menu Insta Equip,Scout|$60000,Light Armor|$70000,Glock|$20000,Flashbang|$30000,Flare|20000]])
		elseif sel == 2 then
			rp_ct_arrest_button(id)
			if tele_sys == 1 then
				if rp_license[id]==true then
					menu(id,[[Teleport Menu@b,Go to position|$5000,Set Current Position,Toggle Spawn Behavior (]]..tsb[id]..[[),]]..ct_57_b)
				else
					rp_msg2(id,[[255000000]],[[[RP] You must to be licenced!]])
				end
			else
				rp_msg2(id,[[255000000]],[[[RP] Teleport System is Disabled!]])
			end
		elseif sel == 3 then
			rp_msg2(id,[[000255000]],[[[RP] Press F1 To see the Help]])
			end
	    elseif sel == 4 then
			menu(id,[[Rent a vehicle part-1,BMW-2003(50k),Old-Ferrari(50K),Toyota(30k),Porche(50k),Infinity(70k),Rent a vehicle part-2]])
		elseif sel == 5 then
			menu(id,[[Rent a license@b,Building License(50k),Vehicle License(50k)]])
			end
the menu will work but u can`t press on [Rent a vehicle part-1] and [Rent a vehicle part-2] and [Rent a license].

ok now this weird if you press on [T Menu Insta Equip] then chose [Flashbang] the [Rent a vehicle part-1] will open then press on [Infinity] the [Rent a vehicle part-2] will open. the same thing for [Rent license] at [flare].

i`m confused i know i have to close each [if] with [end] so i try this
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
if men == [[T Menu]] then
		if sel == 1 then
			menu(id,[[T Menu Insta Equip,Scout|$60000,Light Armor|$70000,Glock|$20000,Flashbang|$30000,Flare|20000]])
			end
		elseif sel == 2 then
			rp_ct_arrest_button(id)
			if tele_sys == 1 then
				if rp_license[id]==true then
					menu(id,[[Teleport Menu@b,Go to position|$5000,Set Current Position,Toggle Spawn Behavior (]]..tsb[id]..[[),]]..ct_57_b)
				else
					rp_msg2(id,[[255000000]],[[[RP] You must to be licenced!]])
				end
			else
				rp_msg2(id,[[255000000]],[[[RP] Teleport System is Disabled!]])
			end
		elseif sel == 3 then
			rp_msg2(id,[[000255000]],[[[RP] Press F1 To see the Help]])
			end
		end
	    elseif sel == 4 then
			menu(id,[[Rent a vehicle part-1,BMW-2003(50k),Old-Ferrari(50K),Toyota(30k),Porche(50k),Infinity(70k),Rent a vehicle part-2]])
		end
		elseif sel == 5 then
			menu(id,[[Rent a license@b,Building License(50k),Vehicle License(50k)]])
			end
when i start the server the whole script didnt work.

anyone know something about this? really weird

Edited : Fixed
edited 1×, last 30.09.10 12:21:18 am
To the start Previous 1 2267 268 269338 339 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview