Pointshop (give/remove/set) commands?

Hey I found this code on pastebin somewhere and I noticed it didn’t work :suicide:
Just wondering if anyone had a working version of the code or could lead me with some helpful tips on how to fix. (sorry I know the code is long)



concommand.Add("ps_givepoints", function(ply, cmd, args)
	-- Give Points
	if ply:IsPlayer() then return false end
	
	local to_give = POINTSHOP.FindPlayerByName(args[1])
	local num = tonumber(args[2])
	
	if not to_give or not num then
		ply:PS_Notify("Please give a name and number!")
		return
	end
	
	if not type(to_give) == "player" then
		if to_give then
			ply:PS_Notify("You weren't specific enough with the name you typed!")
		else
			ply:PS_Notify("No player found by that name!")
		end
	else
		to_give:PS_GivePoints(num, "given by " .. ply:Nick() .. "!")
	end
end)

concommand.Add("ps_takepoints", function(ply, cmd, args)
	-- Take Points
	if ply:IsPlayer() then return false end
	
	local to_take = POINTSHOP.FindPlayerByName(args[1])
	local num = tonumber(args[2])
	
	if not to_take or not num then
		ply:PS_Notify("Please give a name and number!")
		return
	end
	
	if not type(to_take) == "player" then
		if to_take then
			ply:PS_Notify("You weren't specific enough with the name you typed!")
		else
			ply:PS_Notify("No player found by that name!")
		end
	else
		to_take:PS_TakePoints(num, "taken by " .. ply:Nick() .. "!")
	end
end)

concommand.Add("ps_setpoints", function(ply, cmd, args)
	-- Set Points
	if ply:IsPlayer() then return false end
	
	local to_set = POINTSHOP.FindPlayerByName(args[1])
	local num = tonumber(args[2])
	
	if not to_set or not num then
		ply:PS_Notify("Please give a name and number!")
		return
	end
	
	if not type(to_set) == "player" then
		if to_set then
			ply:PS_Notify("You weren't specific enough with the name you typed!")
		else
			ply:PS_Notify("No player found by that name!")
		end
	else
		to_set:PS_SetPoints(num)
		to_set:PS_Notify("Points set to " .. num .. " by " .. ply:Nick() .. "!")
	end
end)


Thanks!

It doesn’t work because it can only be ran from the (edit:** server**) console.

Change all instances of “if ply:IsPlayer() then return false end” to “if !ply:IsAdmin() then return false end”

Aren’t all 3 of these commands accessable in the PointShop menu anyway?

I assume the original reason this was created (not why the OP wants it) was to be able to give points via console, which does not have the pointshop menu, being a server without any VGUI.

Exactly correct, so that our auto donation system could run the command to give points after a donation.