Forum

> > CS2D > Scripts > Lua Error
Forums overviewCS2D overview Scripts overviewLog in to reply

English Lua Error

5 replies
To the start Previous 1 Next To the start

old Lua Error

mr_s
User Off Offline

Quote
i was editing smiley city lua to add autosave but i got this error:
LUA ERROR: sys/lua/Team Boss/Main.lua:390: attempt to compare number with nil
1
2
3
4
5
6
7
8
addhook("minute","rp_minute")
function rp_minute(id)
	
		local USGNid = UsgnIds[id]
		if USGNid > 0 then
			SaveUserStat(id,USGNid)
			rp_msg("000255100","AutoSave!")
	end
line 390 :
1
if USGNid > 0 then

old Re: Lua Error

Dovahkin
User Off Offline

Quote
What is the error?

1
2
3
4
5
6
7
8
9
addhook("minute","rp_minute")
function rp_minute(id)
     
          local USGNid = UsgnIds[id]
          if USGNid = 0 then
               SaveUserStat(id,USGNid)
               rp_msg("000255100","AutoSave!")
     end
end

Edit : I'm just guessing until you state the actual problem.

Edit2x : Probably PM me the whole code instead. ∗

old Re: Lua Error

MikuAuahDark
User Off Offline

Quote
it looks like that: UsgnIds with index id is nil

you could post the join and leave hook instead. and also the Save & Load function

EDIT: i got it. cs2d lua hook minute hook does not have any parameter
Fixed:
1
2
3
4
5
6
7
8
9
addhook("minute","rp_minute")
function rp_minute()
	for _, id in pairs(player(0,"table")) do
		if UsgnIds[id]>0 then
			SaveUserStat(id,UsgnIds[id])
		end
	end
	rp_msg("000255100","AutoSave!")
end

old Re: Lua Error

mr_s
User Off Offline

Quote
good good good, worked

didnt save and didnt make message
edited 1×, last 25.08.13 02:22:30 pm

old Re: Lua Error

omg
User Off Offline

Quote
if it didnt work, u'll want to post the whole script to save time

*in a spoiler, preferably
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview