[ULX/Pointshop 1] Running commands on a players current point amount?

Hello,

I’m adapting a PS2 ULX script I made last year with some help from Facepunch to work with PS1, however I’m running into some issues in the fact that certain equivalents for variables in PS2 don’t exist in PS1. Here’s the PS2 script from last year that works on PS2:



function ulx.rolls (calling_ply, points)
        local p = calling_ply.PS2_Wallet.points 
        if p > points then return false end  
        calling_ply:PS2_AddStandardPoints(-points, "FROM !ROLL")
        
        local victory = (points*10) 
        local ran = (math.random(000001, 1000000)) 
 
        local didYouWin = (ran % 100 % 11 == 0) 
 
        if didYouWin then 
        ulx.fancyLogAdmin( calling_ply, "#A rolled #s. Doubles! They won #s points", ran, victory )
        calling_ply:PS2_AddStandardPoints(victory, "FROM !ROLL")
 
        else
 
                ulx.fancyLogAdmin( calling_ply, "#A rolled #s", ran )
        end
end
 
local roll = ulx.command(CATEGORY_NAME, "ulx rolls", ulx.rolls, "!rolls")
roll:defaultAccess(ULib.ACCESS_ALL)
roll:addParam{ type=ULib.cmds.NumArg, min=0, default=0, max= 1500, hint="Roll", ULib.cmds.optional, ULib.cmds.round }
roll:help("Roll for a chance to win big!.")

I’ve attempted to adapt this for PS1, however this returns the error:


addons/ulx/lua/ulx/modules/sh/rollps!.lua:4: attempt to compare nil with number

The adapted code that makes this error:



function ulx.roll (calling_ply, points)
        local p = calling_ply:PS_GetPoints()
        if p > points then return false end  
        calling_ply:PS_TakePoints(points, "FROM !ROLL")
        
        local victory = (points*10) 
        local ran = (math.random(000001, 1000000)) 
 
        local didYouWin = (ran % 100 % 11 == 0) 
 
        if didYouWin then 
        ulx.fancyLogAdmin( calling_ply, "#A rolled #s. Doubles! They won #s points", ran, victory )
        calling_ply:PS_GivePoints(victory, "FROM !ROLL")
 
        else
 
                ulx.fancyLogAdmin( calling_ply, "#A rolled #s", ran )
        end
end
 
local roll = ulx.command(Multiples, "ulx roll", ulx.roll, "!roll")
roll:defaultAccess(ULib.ACCESS_ALL)
roll:addParam{ type=ULib.cmds.NumArg, min=0, default=0, max= 1500, hint="Roll", ULib.cmds.optional, ULib.cmds.round }
roll:help("Roll for a chance to win big!.")

Does anyone have any idea how I can fix this error? I haven’t much experience with PS1 and the documentation has limited information for this specific thing I’m attempting. I’ve seen this sort of function work on both PS1 and PS2 on various servers, so it must be possible somehow; but I’m completely stumped. There must be some obvious thing I’m missing, but can’t for the life of me figure it out, thank you to any and all help :slight_smile:

Here is documentation for PS1. As you can see, there is no second argument in take and give functions. Try this


function ulx.roll (calling_ply, points)
        local p = calling_ply:PS_GetPoints()
        if p > points then return false end  
        calling_ply:PS_TakePoints(points)
		calling_ply:PS_Notify(Format("%d was taken by !roll", points))
 
        local victory = (points*10) 
        local ran = (math.random(000001, 1000000)) 
 
        local didYouWin = (ran % 100 % 11 == 0) 
 
        if didYouWin then 
        	ulx.fancyLogAdmin( calling_ply, "#A rolled #s. Doubles! They won #s points", ran, victory )
        	calling_ply:PS_GivePoints(victory)
        	calling_ply:PS_Notify(Format("You've got %d from !roll", victory))
        else
			ulx.fancyLogAdmin( calling_ply, "#A rolled #s", ran )
        end
end
 
local roll = ulx.command(Multiples, "ulx roll", ulx.roll, "!roll")
roll:defaultAccess(ULib.ACCESS_ALL)
roll:addParam{ type=ULib.cmds.NumArg, min=0, default=0, max= 1500, hint="Roll", ULib.cmds.optional, ULib.cmds.round }
roll:help("Roll for a chance to win big!.")