Forum

> > CS2D > Scripts > Cigarette script
Forums overviewCS2D overview Scripts overviewLog in to reply

English Cigarette script

22 replies
Page
To the start Previous 1 2 Next To the start

old Cigarette script

Marcell
Super User On Online

Quote
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
addhook("spawn","onJoinAddLigther")
function onJoinAddLighter(lighter,cigarette)
	if Player[id].joined then
	ligther = 0 + 1
	cigarette = 0 + 1
end
end


function OnCigarette(id, lighter, cigarette)
	if ligther = 1 then
	if cigarette => 1 then
		parse("effect "smoke" "..player(id, "x").." "..player(id, "y").." 2 2") 
		end
	
	if lighter = 0 then 
	msg2(id, "©255000000You don't have lighter, buy one at shop!") 
	end  
	if cigarette = 0 then 
	msg2(id, "©255000000You don't have cigarette!") 
	end
end
end

Whats wrong?

old Re: Cigarette script

alex72super
User Off Offline

Quote
First, what's the error?

On line 2:

function onJoinAddLighter(lighter,cigarette)


But on line 4:

ligther = 0 + 1


Check how you wrote 'Lighter'.

old Re: Cigarette script

Rainoth
Moderator Off Offline

Quote
also all checks should be "==" instead of "=" since "=" is declaring the variable.

old Re: Cigarette script

Avo
User Off Offline

Quote
Fixed. Much fix. Many typos, syntax mistakes such as "lighter"/"ligther", few useless lines.

Note that effect of size 5 5 won't be really visible when you call OnCigarette function once.
More >

old Re: Cigarette script

Marcell
Super User On Online

Quote
The problem is not is the full code... i mean i already have player[id] definitions, so it isn't worked at all...
can i show the full code in pm @user Avo: ?

old Re: Cigarette script

Avo
User Off Offline

Quote
I don't see any reason why you shouldn't post it here. Give it here.

old Re: Cigarette script

Marcell
Super User On Online

Quote
Then look at

Spoiler >

Spoiler >

Spoiler >

Spoiler >
edited 1×, last 27.03.14 05:21:02 pm

old Re: Cigarette script

Marcell
Super User On Online

Quote
what???

for me spoiler working fine, when i click to it, it show the full code

old Re: Cigarette script

TheAnonymous
User Off Offline

Quote
@user Marcell: Your file does not work because you did maybe the codes very fast and that you went

LUA ERROR: sys/lua/cigarette.lua:11: 'then' expected near '=' This is the error...

old Re: Cigarette script

Marcell
Super User On Online

Quote
God.. the full code is almost 30 files thats why i also wanted to send it via fileshare

old Re: Cigarette script

TheAnonymous
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
addhook("spawn","onJoinAddLigther")
function onJoinAddLighter(lighter,cigarette)
     if Player[id].joined then
     ligther = 0 + 1
     cigarette = 0 + 1
end
end


function OnCigarette(id, lighter, cigarette)
     if ligther = 1 then
     if cigarette => 1 then
          parse("effect "smoke" "..player(id, "x").." "..player(id, "y").." 2 2") 
          end
     
     if lighter = 0 then 
     msg2(id, "©255000000You don't have lighter, buy one at shop!") 
     end  
     if cigarette = 0 then 
     msg2(id, "©255000000You don't have cigarette!") 
     end
end
end

@user Marcell: Line 11 contains an error

old Re: Cigarette script

MikuAuahDark
User Off Offline

Quote
Line 11
1
if ligther = 1 then

Should me
1
if ligther == 1 then

I don't guarantee that it would not return error attempt to call a nil value

old Re: Cigarette script

Avo
User Off Offline

Quote
you know guys, I've already posted fixed version.

user Marcell has written
God.. the full code is almost 30 files thats why i also wanted to send it via fileshare
Unless you're a pro scripter, you shouldn't use so many separate files. As you see it complicates everything atm, for example - you won't find anyone who want to help you.

One does not simply want to fix 30 files.
To the start Previous 1 2 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview