Is it possible to reset a player's money upon disconnect in DarkRP.

As the title states; is it possible to reset a player’s money upon disconnecting from the server with Dark RP?

Just set the players money when they disconnect.

Reinstall DarkRp everytime the player leaves.



function GM:PlayerDisconnected( ply )
	 ply:addMoney(-9999999999)
end


Enjoy



function GM:PlayerDisconnected( ply )
    if getDarkRPVar("money") > 0 then
        ply:SetDarkRPVar( "money", 0)
    end
end


Are people still trying to get the code for this ridiculous shit?

toss this into whatever autorun you want.




hook.Add("PlayerDisconnected", "ResetTheFuckingMoney", function(ply)
         ply:SetDarkRPVar( "money", GM.Config.startingmoney)
end)

-- Now put this in your crappy server autorun. Ta-da


??

SetDarkRPVar is nil, GM becomes nil after gamemode has loaded, use GAMEMODE.

here…



hook.Add("PlayerDisconnected", "was it so hard", function(ply)
    ply:setDarkRPVar("money", GAMEMODE.Config.startingmoney);

    if (ply.DarkRPUnInitialized) then return; end
    DarkRP.storeMoney(ply, GAMEMODE.Config.startingmoney);
end);


Alternatively you do it whenever a player connects for the first time, as for example the server might crash which will not cause the PlayerDisconnected hook to trigger. While the PlayerInitialSpawn hook will always trigger, no matter what.



hook.Add( "PlayerInitialSpawn", "Reset_Money", function( ply )
	ply:setDarkRPVar( "money", GAMEMODE.Config.startingmoney )
end )


That’ll error, you haven’t defined ply anywhere.

Should be the argument to the function. Just toss an argument in there.

Thanks for pointing out, forgot it ^.^