English Can't find "nil" variable

14 replies
Goto Page
To the start Previous 1 Next To the start
21.02.13 11:44:55 am
Up
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 >
21.02.13 12:19:49 pm
Up
Infinite Rain
Reviewer
Offline Off
Error is here:
Code:
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.
A thousand may fall at your side, ten thousand at your right hand, but it will not come near you. You will only look with your eyes and see the recompense of the wicked. - Psalm 91:7-8 ESV
21.02.13 12:26:14 pm
Up
Thanks, just forgot to rename that. I just kept copy pasting "tank_buy" and didn't notice.
21.02.13 12:30:14 pm
Up
Infinite Rain
Reviewer
Offline Off
Happened to me a lot of times, too.
A thousand may fall at your side, ten thousand at your right hand, but it will not come near you. You will only look with your eyes and see the recompense of the wicked. - Psalm 91:7-8 ESV
21.02.13 12:41:19 pm
Up
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 >
21.02.13 12:50:41 pm
Up
EndDead
User
Offline Off
use the spawn, die and leave hook insted.
what you are doing is generating an image every ms if the player is alive.

/Yates
21.02.13 01:00:38 pm
Up
@user EndDead: Now it doesn't follow the player.
21.02.13 01:03:52 pm
Up
EndDead
User
Offline Off
Then you did not use the correct settings upon creating an image.

http://cs2d.com/help.php?luacat=image&luacmd=image#cmd - Check the cs2d.com/help out for any Lua or server issues.

/Yates
21.02.13 01:10:48 pm
Up
This is what is happening, if you look to the right, there are 3 CTs, 2 of them have no sprites.
IMG:http://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.
edited 2×, last 22.02.13 05:59:38 am
22.02.13 05:15:53 pm
Up
Yates
Reviewer
Offline Off
@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.
24.02.13 09:24:38 am
Up
@user Yates: Your suggestion helped, but I want the "tankimg[id]" to not rotate with the player AND rotate with "tankrot[id]". It still rotates to the player even if X = 0.
24.02.13 10:51:27 am
Up
EngiN33R
Moderator
Offline Off
user Obviously Exactly Myself has written:
It still rotates to the player even if X = 0.


Then you're doing something wrong. Check if you've set x to 0 in every occurrence of image() (if there's more than one).
I code, therefore I exist. | Visit my blog for Lua tips and other interesting info
25.02.13 12:16:22 pm
Up
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.
edited 2×, last 26.02.13 12:49:46 pm
26.02.13 01:27:52 pm
Up
EngiN33R
Moderator
Offline Off
Try changing your tank_always function to this.

Code:
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
I code, therefore I exist. | Visit my blog for Lua tips and other interesting info
26.02.13 01:46:45 pm
Up
Oh, I thought that command only sets the position and rotation.
Thanks a lot.
To the start Previous 1 Next To the start