Author Topic: Help with setOpposite  (Read 1685 times)

0 Members and 1 Guest are viewing this topic.

Offline JasonMan

  • Newbie
  • *
  • Posts: 12
  • Karma: -1
Help with setOpposite
« on: February 08, 2016, 12:28:51 PM »
I have this command called uservip (Sets a value), and I tried to set an opposite command that will retrieve the value, and for the life of me I have no idea what I'm doing wrong.
uservip works fine.
getuservip as a completely different command (Not as a setOpposite) works fine.
But for some reason, when I use this code, something f***s up

ULib v3.62
ULX v2.52

Code: [Select]
function ulx.uservip( calling_ply, target_ply, vipvalue, should_get )
local err_msg = "Cannot set VIP value to a bot"
calling_ply:ChatPrint( tostring( should_get ) ) //Debug - returns false when it should be false. Returns nil when it should be true
if should_get then err_msg = "Bots don't have VIP values." end
if target_ply:IsBot() then
ULib.tsayError( calling_ply, err_msg, true )
return
end

if should_get then
if vipvalue > 3 or vipvalue < 1 then
ULib.tsayError( calling_ply, "The VIP value must be between 1 and 3!", true )
return
end
end

// if not target_ply:IsVIP() then ULib.tsayError ( calling_ply, target_ply:Nick() .. " is not a VIP" ) return end
if not should_get then
ulx.fancyLogAdmin( nil, true, "#T's VIP value is set to " .. target_ply:GetVIPValue(), target_ply, vipvalue )
else
target_ply:SetVIPValue( vipvalue )
ulx.fancyLogAdmin( calling_ply, true, "#A set #T" .. "'s VIP value to #s", target_ply, vipvalue )
end
end

local uservip = ulx.command( CATEGORY_NAME, "ulx uservip", ulx.uservip, "!uservip" )
uservip:addParam{ type=ULib.cmds.PlayerArg }
uservip:addParam{ type=ULib.cmds.NumArg, hint="Set a user's VIP value." }
uservip:addParam{ type=ULib.cmds.BoolArg, invisible=true }
uservip:setOpposite( "ulx getuservip", { _, _, _, true }, "!getuservip", true )
uservip:defaultAccess( ULib.ACCESS_SUPERADMIN )
uservip:help( "1 = Minimal donation\n2 = Medium donation\n3 = Big donation" )
« Last Edit: February 08, 2016, 01:42:40 PM by JasonMan »

Offline Bytewave

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 718
  • Karma: 116
  • :)
    • My Homepage
Re: Help with setOpposite
« Reply #1 on: February 08, 2016, 01:38:53 PM »
"something f***s up" isn't exactly very helpful.

Check your server/client console. Are you getting any Lua errors?
bw81@ulysses-forums ~ % whoami
Homepage

Offline JasonMan

  • Newbie
  • *
  • Posts: 12
  • Karma: -1
Re: Help with setOpposite
« Reply #2 on: February 08, 2016, 01:46:25 PM »
"something f***s up" isn't exactly very helpful.

Check your server/client console. Are you getting any Lua errors?

*sigh*
Apparently I hadn't removed the setup for getuservip as its own command, only the function itself.
There goes 1.5 hours of my life for nothing x.x