Forum

> > CS2D > Scripts > Can't find "nil" variable
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Can't find "nil" variable

14 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Can't find "nil" variable

Obviously Exactly Myself
User Off Offline

Zitieren
There was some bug happening to my script, I think it was because it gives me an error message every 10 seconds.
The error message was "LUA ERROR: attempt to call a nil value".
It didn't tell what line, I took me hours trying to find the line.

Script >

alt Re: Can't find "nil" variable

Infinite Rain
Reviewer Off Offline

Zitieren
Error is here:
1
2
3
4
5
--No buying
addhook("buy","tank_buy")
function tank_drop(id,x,y)
     return 1
end

Try to find it yourself.

Hint: Lua error that is without line, means that one of the hooks don't have a function.

alt Re: Can't find "nil" variable

Obviously Exactly Myself
User Off Offline

Zitieren
Another question:
There is something wrong with the "ms100" hook, when a player spawns, there is a lot of chance that the 2 images gets removed and rarely, appears minutes later.

New MS100 Hook >

alt Re: Can't find "nil" variable

EndDead
User Off Offline

Zitieren
use the spawn, die and leave hook insted.
what you are doing is generating an image every ms if the player is alive.

/Yates

alt Re: Can't find "nil" variable

Obviously Exactly Myself
User Off Offline

Zitieren
This is what is happening, if you look to the right, there are 3 CTs, 2 of them have no sprites.
IMG:https://s15.postimage.org/5qhtkg6qz/tank_grassy_00003.jpg

Sometimes, it only shows the cannon or the base only.

BTW, >


---EDIT---

@user EndDead: It only tells what are the lua stuff but it doesn't fix your script.
2× editiert, zuletzt 22.02.13 05:59:38

alt Re: Can't find "nil" variable

Yates
Reviewer Off Offline

Zitieren
@user Obviously Exactly Myself: You need to use the correct image options to make the image follow the player. Use the damn spawn, die and leave hook. Your script is basically rubbish.

Also cs2d.com/help is not there to magically fix your scripts as it couldn't possibly know what you want. It is there for help and help only. Do not script if you cannot even read properly from a site that is there to help you.

alt Re: Can't find "nil" variable

Obviously Exactly Myself
User Off Offline

Zitieren
Part of the script:
Spoiler >

Those are the only parts with the word "image" in it.

EDIT: BTW, if none understands much, I meant that I want "tankimg" to rotate to "tankrot" with the "tankpic" rotating to the player.
As the button above shows.
2× editiert, zuletzt 26.02.13 12:49:46

alt Re: Can't find "nil" variable

EngiN33R
Moderator Off Offline

Zitieren
Try changing your tank_always function to this.

1
2
3
4
5
6
7
8
--Position tank
addhook("always","tank_always")
function tank_always()
     local playerlist=player(0,"tableliving")
     for _,id in pairs(playerlist) do
          imagepos(tankimg[id],0,1,tankrot[id])
     end
end
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht