FPtje / DarkRP

DarkRP, a non-serious roleplay gamemode for Garry's Mod.
https://darkrp.miraheze.org
MIT License
467 stars 710 forks source link

Little microwave error #1952

Closed UltimateByte closed 9 years ago

UltimateByte commented 9 years ago

I'm sorry i don't know the context of this error, just spotted that into server console :

[DarkRP] gamemodes/darkrp/entities/entities/microwave/init.lua:87: attempt to call method 'addMoney' (a nil value)

  1. unknown - gamemodes/darkrp/entities/entities/microwave/init.lua:87
Shigbeard commented 9 years ago

uh, this seems like an "Update DarkRP" bug.

UltimateByte commented 9 years ago

Yay, update 3 hours ago, gotta reboot the server. That's pretty damn fast : only 1 day after gmod update (that of course broke a few addons). GG guyz ! fingers crossed

Shigbeard commented 9 years ago

Welcome to Garry's Mod. Please enjoy your time here in hell.

UltimateByte commented 9 years ago

Oh i'm not new... Just a bit new to DarkRP, and i'm glad to see devs are very fast. Sorry if i seemed sarcastic, i wasn't ! And well... thanks !

tgrgds commented 9 years ago

Has this been fixed?

UltimateByte commented 9 years ago

I made a dupe of my server with MySQL and everything onto a local Debian VM this night, to work and run tests. I'll try to load gmod with premiere video exporting and spam microwaves and use them and tell ya. As it'll be solo i won't be able to try someone else using my microwave btw. (as i said, i don't know the context of that error, i just spotted it into the server console)

UltimateByte commented 9 years ago

Well at least if i buy food from it : no error. Now i can't tell you what happens if someone else buys from my microwave.

FPtje commented 9 years ago

Does your server have an alternative way of spawning the microwave? (i.e. Not through the f4 menu or chat command)

UltimateByte commented 9 years ago

Yeah, now you say that, we can pop it from ItemStore inventory. I was gonna try that but no need : I reconnected to the server and saw the microwave was still here... So I tried using it again and got the error back. In that case it only had the electric effect and nothing poped out. The same thing happens if i try to store the item and retrieving it after a server reboot. Should i say i had it into inventory then put it back on the ground and it was still working before i disconnected/reconnected. As this behaviour (which i liked as storing a microwave isn't so realistic) happened before gmod update, i guess the error was already there too but i just didn't notice it.

UltimateByte commented 9 years ago

I spawned a new microwave (even if the limit is 1 microwave, as the first one didn't belong to me anymore) I set FPP cleanup to 4 seconds. Then i disconnected for 10 seconds, then reconnected. The second microwave worked OK I put that second microwave into inventory, then made a "retry" Spawned that microwave back : error again. Notice : every time i put it back into inventory then spawn it back, the effect disappears, and money is drained the first time i press "use" on it.

So it's putting them into IntemStore's inventory that is causing that.

Should i contact Olivia (itemStore's dev) or do you estimate this as a DarkRP issue ?

FPtje commented 9 years ago

Entities spawned through the f4 menu have a dt var set called "owning_ent". Not setting that var causes that error. How do you register things with itemstore? Surely there's a custom spawn and store function?

UltimateByte commented 9 years ago

It seems to be handelled already. Maybe there's a mistake somewhere else into the code but then i'm not qualified enough to find it.

In itemstore/lua/itemstore/items there is a microwave.lua :


ITEM.Name = "Microwave" ITEM.Description = "Why is it always burning hot on the outside but freezing in the middle!?" ITEM.Model = "models/props/cs_office/microwave.mdl" ITEM.Base = "base_darkrp"

function ITEM:SaveData( ent ) self:SetData( "Price", ent:Getprice() ) self:SetData( "Owner", ent:Getowning_ent() ) end

function ITEM:LoadData( ent ) ent:Setprice( self:GetData( "Price" ) ) ent:Setowning_ent( self:GetData( "Owner" ) ) end

FPtje commented 9 years ago

Use SteamID if you allow people to reconnect and then spawn it.

Also, you should store the .SID value On 3 Jun 2015 13:23, "UltimateByte" notifications@github.com wrote:

It seems to be handelled already. Maybe there's a mistake somewhere else into the code but then i'm not qualified enough to find it.

In itemstore/lua/itemstore/items there is a microwave.lua :

ITEM.Name = "Microwave" ITEM.Description = "Why is it always burning hot on the outside but freezing in the middle!?" ITEM.Model = "models/props/cs_office/microwave.mdl" ITEM.Base = "base_darkrp"

function ITEM:SaveData( ent ) self:SetData( "Price", ent:Getprice() ) self:SetData( "Owner", ent:Getowning_ent() ) end

function ITEM:LoadData( ent ) ent:Setprice( self:GetData( "Price" ) ) ent:Setowning_ent( self:GetData( "Owner" ) ) end

— Reply to this email directly or view it on GitHub https://github.com/FPtje/DarkRP/issues/1952#issuecomment-108310850.

UltimateByte commented 9 years ago

I'm just a little geek, i just know the very basics of coding. It definately goes beyond my knowledge, i'll call Olivia.

FPtje commented 9 years ago

self:SetData( "SID", ENT.SID)

UltimateByte commented 9 years ago

This is for the SaveData right ? For LoadData will it be : ent:SetData( self:GetData( "SID" ) ) ?

Won't it lack an entry into the database ? As i said, i don't really do code, i just tweak some things and learned a bit more to repair the Drilldo recently... :p

BTW, i asked Olivia to come here, as this will need to get fixed by the dev anyways.

FPtje commented 9 years ago

ent.SID = self:GetData( "SID" )

UltimateByte commented 9 years ago

So i end up with :

ITEM.Name = "Microwave" ITEM.Description = "Why is it always burning hot on the outside but freezing in the middle!?" ITEM.Model = "models/props/cs_office/microwave.mdl" ITEM.Base = "base_darkrp"

function ITEM:SaveData( ent ) self:SetData( "Price", ent:Getprice() ) self:SetData( "SID", ENT.SID) self:SetData( "Owner", ent:Getowning_ent() ) end

function ITEM:LoadData( ent ) ent:Setprice( self:GetData( "Price" ) ) ent:Setowning_ent( self:GetData( "Owner" ) ) ent.SID = self:GetData( "SID" ) end

Still the exact same issue after respawning the microwave after a "retry". It probably lacks some entries into the database...

FPtje commented 9 years ago

Lowercase ent in SetData. Blame tablet keyboard.

UltimateByte commented 9 years ago

I should have seen it but i trusted you like a sheep following his sheepdog. Yeah, you're like a sheepdog to me. I'm so poetic today...

It still doesn't work with self:SetData( "SID", ent.SID) :(

FPtje commented 9 years ago

The issue in the end is that the owning_ent is nil. I don't know what causes it, but I have enough reasons to believe it's that item thing.

Discussion can continue in this issue.

UltimateByte commented 9 years ago

Thanks for your attention, all of you ;) I may open another thread to discuss about MySQL performance after investigating a bit more. Maybe i could open it somewhere else you prefer ?

tgrgds commented 9 years ago

I'm pretty sure @FPtje 's standard is to just post it on the forums first, so that'll do.

Jitterclick commented 9 years ago

Wow you are exotic @TylerGeorges