• Networking Integer issues
    2 replies, posted
Well, I'm trying to take away from a Network integer, in this case it's money on a gamemode I'm developing ( Not roleplay ), and it just won't do it. Here is where I first apply the NWInt on the player, Initial spawn, I set it to 100. [code] function GM:PlayerInitialSpawn( ply ) Load( ply ) ply:SetNWInt("Currency", 100) -- Set their money for the first time. ConnectingStatus( ply ) RunConsoleCommand( "bg_run" ) end [/code] Now here is what I'm doing, whenever someone kills someone, they get 100 dollars. Whenever someone dies/commits suicide, they lose 10 dollars. Here's the death hook. [code] function GM:PlayerDeath( Victim, Inflictor, Attacker ) if ( Inflictor and Inflictor == Attacker and ( Inflictor:IsPlayer() or Inflictor:IsNPC() ) ) then Inflictor = Inflictor:GetActiveWeapon() if ( !Inflictor or Inflictor == NULL ) then Inflictor = Attacker end end if ( Attacker == Victim ) then MsgAll( Attacker:Nick() .. " suicided!\n" ) Attacker:SetNWInt( "Money", Attacker:GetNWInt( "Money" ) - 10 ) return end if ( Attacker:IsPlayer() ) then MsgAll( Attacker:Nick() .. " killed " .. Victim:Nick() .. " using " .. Inflictor:GetClass() .. "\n" ) Attacker:SetNWInt( "Money", Attacker:GetNWInt( "Money" ) + 100 ) Victim:SetNWInt( "Money", Attacker:GetNWInt( "Money" ) - 10 ) return end MsgAll( Victim:Nick() .. " was killed by " .. Attacker:GetClass() .. "\n" ) end [/code] And this is how I'm checking the value of the NWInt [code] function PrintCurrency( ply ) Msg( ply:GetNWInt("Currency") ) end concommand.Add("MyMoney", PrintCurrency ) [/code] Please respond as soon as possible! No errors, nothing. The only thing I can think of is if NWInts reset on death, but after I type suicide in console, then put in my command, it still says my currency is 100? So it's just not going anywere.
Bump, still need help.
You're setting "Currency" on the player initial spawn, yet you're setting "Money" on the player death? Shouldn't it be Currency?
Sorry, you need to Log In to post a reply to this thread.