• Is it possible to reset a player's money upon disconnect in DarkRP.
    10 replies, posted
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.
[CODE] function GM:PlayerDisconnected( ply ) ply:addMoney(-9999999999) end [/CODE] Enjoy
[CODE] function GM:PlayerDisconnected( ply ) if getDarkRPVar("money") > 0 then ply:SetDarkRPVar( "money", 0) end end [/CODE]
Are people still trying to get the code for this ridiculous shit? toss this into whatever autorun you want. [code] hook.Add("PlayerDisconnected", "ResetTheFuckingMoney", function(ply) ply:SetDarkRPVar( "money", GM.Config.startingmoney) end) -- Now put this in your crappy server autorun. Ta-da [/code]
?? SetDarkRPVar is nil, GM becomes nil after gamemode has loaded, use GAMEMODE. here... [code] 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); [/code]
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. [code] hook.Add( "PlayerInitialSpawn", "Reset_Money", function( ply ) ply:setDarkRPVar( "money", GAMEMODE.Config.startingmoney ) end ) [/code]
[QUOTE=GalaxyBeatzz;52565342]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. [code] hook.Add( "PlayerInitialSpawn", "Reset_Money", function() ply:setDarkRPVar( "money", GAMEMODE.Config.startingmoney ) end ) [/code][/QUOTE] That'll error, you haven't defined ply anywhere.
[QUOTE=Promptitude;52568429]That'll error, you haven't defined ply anywhere.[/QUOTE] Should be the argument to the function. Just toss an argument in there.
[QUOTE=Promptitude;52568429]That'll error, you haven't defined ply anywhere.[/QUOTE] Thanks for pointing out, forgot it ^.^
Sorry, you need to Log In to post a reply to this thread.