Forum

> > CS2D > Scripts > Cigarette script
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Cigarette script

22 Antworten
Seite
Zum Anfang Vorherige 1 2 Nächste Zum Anfang

alt Cigarette script

Marcell
Super 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
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?

alt Re: Cigarette script

alex72super
User Off Offline

Zitieren
First, what's the error?

On line 2:

function onJoinAddLighter(lighter,cigarette)


But on line 4:

ligther = 0 + 1


Check how you wrote 'Lighter'.

alt Re: Cigarette script

Rainoth
Moderator Off Offline

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

alt Re: Cigarette script

Avo
User Off Offline

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

alt Re: Cigarette script

Marcell
Super User Off Offline

Zitieren
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: ?

alt Re: Cigarette script

Avo
User Off Offline

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

alt Re: Cigarette script

Marcell
Super User Off Offline

Zitieren
Then look at

Spoiler >

Spoiler >

Spoiler >

Spoiler >
1× editiert, zuletzt 27.03.14 17:21:02

alt Re: Cigarette script

Marcell
Super User Off Offline

Zitieren
what???

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

alt Re: Cigarette script

TheAnonymous
User Off Offline

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

alt Re: Cigarette script

Marcell
Super User Off Offline

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

alt Re: Cigarette script

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

alt Re: Cigarette script

MikuAuahDark
User Off Offline

Zitieren
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

alt Re: Cigarette script

Avo
User Off Offline

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

user Marcell hat geschrieben
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.
Zum Anfang Vorherige 1 2 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht