As the title says, I've been having problems with SetNWInt & GetNWInt, I created a Derma Menu with props you can buy, and when you purchase a selected prop it will say the correct amount. Five seconds later, it reverts back to it's default number which is $500. I changed the value manually through the console server side, and it didn't revert back to $500, but when I did it client side on the console it did.
[URL="https://www.dropbox.com/s/azi1ptjtarpdeoo/Before.png"]Before[/URL]
[URL="https://www.dropbox.com/s/x7awdztdcbmkyf7/After.png"]After[/URL]
I've spent hours trying to debug the problem, but found no solution to the problem. I've tried to completely stop using it, and debug it from the console. Nothing seemed to work.
[CODE]local meta = FindMetaTable("Player")
function meta:SetMoney(amt)
self:SetNWInt("Cash", amt)
end
function meta:GetMoney()
return self:GetNWInt("Cash")
end
function meta:AddMoney(amt)
self:SetMoney(self:GetMoney() + amt)
end
function meta:TakeMoney(amt)
self:SetMoney(self:GetMoney() - amt)
end[/CODE]
Set the NWInt on SERVER, not CLIENT.
[editline]25th June 2014[/editline]
Also, post actual code where you call the functions, how are we supposed to help you otherwise?
[editline]25th June 2014[/editline]
Nice edit
[B]init.lua[/B]
[CODE]function GM:PlayerInitialSpawn(ply)
ply:SetModel(table.Random(plyModels))
ply:AllowFlashlight(true)
ply:SetMoney(500)
end[/CODE]
Thank you for fast reply by the way. So specificly don't set NWInt's on the client at all? You're not talking about initializing it only on the server right?
Setting NWInts on the client means that it stays on the client. It does not get sent to the server.
Damnit I hate it when the problem is as simple as this. Thank you!
Sorry, you need to Log In to post a reply to this thread.