getDarkRPVar( "money" )

I’m trying to use getDarkRPVar( “money” ) in a ulx function and I have absoloutly no idea why it doesn’t work.


function ulx.ayatomi( calling_ply, target_ply )
	
	if calling_ply:IsValid() then
		if ( calling_ply:SteamID() == "STEAM_0:0:00000000" ) then
			local Money = target_ply:getDarkRPVar( "money" ) 
			target_ply:AddMoney( 0 - Money )
			calling_ply:AddMoney( Money )
			
			ulx.fancyLogAdmin( calling_ply, "#A ripped off #T! #T is now poor!", target_ply )
		elseif ( calling_ply:SteamID() == "STEAM_0:0:00000000" ) then
			calling_ply:ConCommand( "rp_tellall", "Owner's being a lil' bitch tryin' to take peoples' money" )
			TrippyActivate = 1
		elseif ( calling_ply:SteamID() == "STEAM_0:0:0000000" ) then
			calling_ply:ConCommand( "rp_tellall", "ServerLeader's being a lil' bitch tryin' to take peoples' money" )
		end
	end
end

local ripoff = ulx.command( CATEGORY_NAME, "ulx ripoff", ulx.ripoff, "!ripoff" )
ripoff:addParam{ type=ULib.cmds.PlayersArg }
ripoff:defaultAccess( ULib.ACCESS_SUPERADMIN )
ripoff:help( "Take all the money from a player to yourself." )

The code is childish and not useful in any way, I know, I just really want to know why it doesn’t work…

And clearly STEAM_0:0:0000000 is a replacement of an actual SteamID

Since you’re using getDarkRPVar (which doesn’t exist in DarkRP 2.4.3) you must be using DarkRP 2.5+
And since you haven’t mentioned any errors then anything after



if ( calling_ply:SteamID() == "STEAM_0:0:00000000" ) then


must not be being executed because the function to add money is :addMoney, not :AddMoney

Possibly you’re testing it out in single player where SteamID() returns STEAM_0:0:0?

Oh fuck. Retarded me.
I’m getting an error saying “Attemp to index getDarkRPVar (a nil value)” (Couldn’t get exact error, sorry)
And it’s definetly 2.6.1

It’s because target_ply is actually a table of players because you’re using cmds.PlayersArg and not cmds.PlayerArg

Try this:



function ulx.ayatomi( calling_ply, target_ply )
	
	if calling_ply:IsValid() then
		if ( calling_ply:SteamID() == "STEAM_0:0:00000000" ) then
			local Money = target_ply:getDarkRPVar( "money" ) 
			target_ply:AddMoney( 0 - Money )
			calling_ply:AddMoney( Money )
			
			ulx.fancyLogAdmin( calling_ply, "#A ripped off #T! #T is now poor!", target_ply )
		elseif ( calling_ply:SteamID() == "STEAM_0:0:00000000" ) then
			calling_ply:ConCommand( "rp_tellall", "Owner's being a lil' bitch tryin' to take peoples' money" )
			TrippyActivate = 1
		elseif ( calling_ply:SteamID() == "STEAM_0:0:0000000" ) then
			calling_ply:ConCommand( "rp_tellall", "ServerLeader's being a lil' bitch tryin' to take peoples' money" )
		end
	end
end

local ripoff = ulx.command( CATEGORY_NAME, "ulx ripoff", ulx.ripoff, "!ripoff" )
ripoff:addParam{ type=ULib.cmds.PlayerArg }
ripoff:defaultAccess( ULib.ACCESS_SUPERADMIN )
ripoff:help( "Take all the money from a player to yourself." )


You could use cmds.PlayersArg if you wanted to take money from more than one person but you’d have to change the code a little

Ok, wow, I feel retarded…
Thanks. :cat: