• EXP/Money system help...
    93 replies, posted
that wasn't helpful, that was just you saying how unhelpful i was
How is it not useful even though it answers his questions.
Science caters to all of the crappy lua noobs/bad community owners that no one else will help. Such as Toby Biggs. But he can code, some.
[QUOTE=cis.joshb;29646880]Science caters to all of the crappy lua noobs/bad community owners that no one else will help[/QUOTE] Because he is one
ITT: Science vs world.
[QUOTE=Amic;29648587]ITT: Science vs world.[/QUOTE] And the world won
Really it's so easy to beat Science that it's not even funny anymore
Hey i searched "ass" in google Guess who i found. [url]http://www.facepunch.com/members/401278-c-unitV2[/url]
[QUOTE=Christian;29739455]Hey i searched "ass" in google Guess who i found. [url]http://www.facepunch.com/members/401278-c-unitV2[/url][/QUOTE] You bumped a 3 days old thread to write something not funny?
[QUOTE=Freze;29739466]You bumped a 3 days old thread to write something not funny?[/QUOTE] I think its rather funny.
[QUOTE=Science;29739500]I think its rather funny.[/QUOTE] That's you. Who's counting you in?
calm down Freze
I got an easier solution, don't use NWInt's unless you want a laggy ass gamemode, it's okay to use 1 not so much 2 but here: Nothing special either. [lua] local meta = FindMetaTable("Player") function meta:SetDollars(amount) self.Dollars = amount umsg.Start("sendDollars",self) -- Oh and Clientside make a usermessage hook to recieve this amount. umsg.Long(amount) umsg.End() self:SetPData("Dollars",amount) end function meta:GetDollars() return self.Dollars or 0 end function meta:AddDollars(amount) self:SetDollars(self:GetDollars()+amount) end function meta:TakeDollars(amount) self:SetDollars(math.Max(0,self:GetDollars()-amount)) end [/lua] [QUOTE=Freze;29741937]That's you. Who's counting you in?[/QUOTE] He's counting himself, clearly. Stop causing problems.
[QUOTE=jrj996;29743829]I got an easier solution, don't use NWInt's unless you want a laggy ass gamemode, it's okay to use 1 not so much 2 but here: Nothing special either. [lua] local meta = FindMetaTable("Player") function meta:SetDollars(amount) self.Dollars = amount umsg.Start("sendDollars",self) -- Oh and Clientside make a usermessage hook to recieve this amount. umsg.Long(amount) umsg.End() self:SetPData("Dollars",amount) end function meta:GetDollars() return self.Dollars or 0 end function meta:AddDollars(amount) self:SetDollars(self:GetDollars()+amount) end function meta:TakeDollars(amount) self:SetDollars(math.Max(0,self:GetDollars()-amount)) end [/lua] He's counting himself, clearly. Stop causing problems.[/QUOTE] I think im gonna get to like you around here. [lua]usermessage.Hook("sendDollars", function (um) local money = um:ReadLong() end) --Simple way of returning the players money clientside, can be used in huds and everything. [/lua]
[QUOTE=Science;29744062]I think im gonna get to like you around here. [lua]usermessage.Hook("sendDollars", function (um) local money = um:ReadLong() end) --Simple way of returning the players money clientside, can be used in huds and everything. [/lua][/QUOTE] money is local to the usermessage hook making it useless
[QUOTE=c-unitV2;29744146]money is local to the usermessage hook making it useless[/QUOTE] It can save ram, it's optimizing a gamemode. Unless thats returning the variable, whatever.
[QUOTE=jrj996;29744239]It can also save ram, it's optimizing a gamemode. Unless thats returning the variable, whatever.[/QUOTE] We all notice the loss of 4 bytes these days. [editline].[/editline] But at least you're feeding the GC.
[QUOTE=FlapadarV2;29744259]We all notice the loss of 4 bytes these days.[/QUOTE] I didn't realize you were coding his gamemode, maybe he's doing a lot of lines of code? Or maybe someones learning from this thread. 4 bytes being saved is better than 0.
[QUOTE=jrj996;29744288]I didn't realize you were coding his gamemode, maybe he's doing a lot of lines of code? Or maybe someones learning from this thread. 4 bytes being saved is better than 0.[/QUOTE] But it's 4 bytes...
[QUOTE=jrj996;29744288]I didn't realize you were coding his gamemode, maybe he's doing a lot of lines of code? Or maybe someones learning from this thread. 4 bytes being saved is better than 0.[/QUOTE] [lua] --[[ Memory Leak V1.0 Flapadar &copyright; 2011 ]] print(collectgarbage("count")) for i = 1 , 1000000000 do local shit = math.random(-2147483648 , 2147483647) end collectgarbage() print(collectgarbage("count"))[/lua]
:V
that memory leak code is quite useful!
*you're
You're not using local because it "saves memory", you are using local because it is a proper style of writing code. After all, there's no reason that your variables lie around, wasting space and probably impact other code. Coming from C++, I expect all variables to be nil at the beginning of a block (except global and member ones, of course, but those are rather rare) and to become nil at the end of one. Also, I'd see that as a snippet - "Here, do with money whatever you want", not as complete code.
[QUOTE=Zaubermuffin;29746303]You're not using local because it "saves memory", you are using local because it is a proper style of writing code. After all, there's no reason that your variables lie around, wasting space and probably impact other code. Coming from C++, I expect all variables to be nil at the beginning of a block (except global and member ones, of course, but those are rather rare) and to become nil at the end of one. Also, I'd see that as a snippet - "Here, do with money whatever you want", not as complete code.[/QUOTE] let me clean up his code real quick then [lua] local money = nil usermessage.Hook("sendDollars", function( um ) money = um:ReadLong() end) money = nil [/lua]
Lol, was that a trolling attempt there Freze? And he even got banned the same day clearly a troll. And how was that not funny? If you only came to facepuch to troll then go find a troller forum where you can discuss who and how to troll please.
13 new posts
It was for use inside the hook you idiot, not a complete code. It can be used for many things inside the hook such as Huds and dermas.
[QUOTE=Christian;29747334]Lol, was that a trolling attempt there Freze? And he even got banned the same day clearly a troll. And how was that not funny? If you only came to facepuch to troll then go find a troller forum where you can discuss who and how to troll please.[/QUOTE] I'll get a troller forum. If you'll go to fastthreads.
[QUOTE=c-unitV2;29746630]let me clean up his code real quick then [lua] local money = nil usermessage.Hook("sendDollars", function( um ) money = um:ReadLong() end) money = nil [/lua][/QUOTE] [lua] local money usermessage.Hook("sendDollars", function( um ) money = um:ReadLong() end) [/lua]
Sorry, you need to Log In to post a reply to this thread.