Hi for some reason this code doesn't work? It doesn't list the players in the server? Im trying to make it say yes if they are in the usergroup vip, but it doesnt list any players on it when its opened.
Any ideas?
[lua]local VIP_ENABLED = true
local DONATE_URL = "url here"
function ulx.vip( calling_ply )
if not VIP_ENABLED then return calling_ply:PrintMessage( HUD_PRINTTALK, "Buying VIP is currently disabled... check back another time." ) end
umsg.Start( "VIPDonate", calling_ply ) umsg.End()
end
local vip = ulx.command( "Utility", "ulx vip", ulx.vip, "!vip" )
vip:defaultAccess( ULib.ACCESS_ALL )
vip:help( "Opens the donation menu" )
usermessage.Hook( "VIPDonate", function( um )
local DermaPanel = vgui.Create( "DFrame" )
DermaPanel:SetPos( 50, 50 )
DermaPanel:SetSize( 300, 225 )
DermaPanel:Center()
DermaPanel:SetTitle( "VIP Donation Menu" )
DermaPanel:SetVisible( true )
DermaPanel:SetDraggable( true )
DermaPanel:ShowCloseButton( true )
DermaPanel:MakePopup()
local DermaListView = vgui.Create("DListView")
DermaListView:SetParent( DermaPanel )
DermaListView:SetPos( 25, 50 )
DermaListView:SetSize( 250, 150 )
DermaListView:SetMultiSelect( false )
local Nick = DermaListView:AddColumn( "Name" )
Nick:SetMinWidth( 128 )
Nick:SetMinWidth( 128 )
DermaListView:AddColumn( "Is VIP" )
DermaListView:AddColumn( "Friend" )
for _, v in pairs( player.GetAll() ) do
if v:CheckGroup( "moderator" ) or v:IsAdmin() then continue end -- moderator and up get VIP default.
local IsVIP = (IsValid(v) and v.IsVIP and v:IsVIP()) and "Yes" or "No"
local IsFriend = "No"
if v:GetFriendStatus() == "friend" then IsFriend = "Yes" end
local Line = DermaListView:AddLine( v:Nick(), IsVIP, IsFriend )
Line.IsVIP = v:IsVIP()
Line.SteamID = v:SteamID()
end
local function DonateFor( SteamID )
if not SteamID or SteamID == "NULL" then return end
gui.OpenURL( DONATE_URL .. "&custom=" .. SteamID )
LocalPlayer():PrintMessage( HUD_PRINTTALK, "When you donate, it takes around 1-2 minutes for it to process your donation to add you to VIP, once done it'll notice you in chatbox." )
LocalPlayer():PrintMessage( HUD_PRINTTALK, "You won't see a notification when you extend your VIP time, you can re-open this menu to check if your VIP expire date has changed." )
DermaPanel:Close()
end
local function OpenMenu( Info, Line )
local Panel = Info:GetLine( Line )
if Panel then
local Nick = Panel:GetValue( 1 )
local IsVIP = Panel.IsVIP
local SteamID = Panel.SteamID
local Popup = DermaMenu()
if IsVIP then
if SteamID == LocalPlayer():SteamID() then
Popup:AddOption( "Extend your VIP by two months", function() DonateFor( SteamID ) end )
else
Popup:AddOption( "Extend " .. Nick .. "'s VIP by two months", function() DonateFor( SteamID ) end )
end
else
if SteamID == LocalPlayer():SteamID() then
Popup:AddOption( "Buy VIP for yourself", function() DonateFor( SteamID ) end )
else
Popup:AddOption( "Buy VIP for " .. Nick, function() DonateFor( SteamID ) end )
end
end
Popup:Open()
end
end
DermaListView.OnRowSelected = OpenMenu
DermaListView.OnRowRightClick = OpenMenu
end )
[/lua]
Without the error, it's a little hard to pinpoint the exact problem
Howvere, if it is erroring at the point you say, I'm guessing that IsVIP isn't a valid function or v isn't a valid player
Something like this should prevent errors:
[lua] local IsVIP = "No"
if IsValid(v) and v.IsVIP and v:IsVIP() then IsVIP = "Yes" end[/lua]
Or, I would personally do something more like this:
[lua] local IsVIP = (IsValid(v) and v.IsVIP and v:IsVIP()) and "Yes" or "No"[/lua]
ok so if your not admin you get this error.
error line 42 attempt to call method 'IsVIP' a nil value.
Yeah, so it was as I guessed, then
Just replace your check with one of the two I posted, and it should be fine
Ok thanks. New error :p. I updated the code in my first post as it currently stands.
[lua][ERROR] lua/autorun/client/blah.lua:47: attempt to call method 'IsVIP' (a nil value)
1. Function - lua/autorun/client/blah.lua:47
2. unknown - lua/includes/modules/usermessage.lua:87
[/lua]
bump. Hoping to get this fixed asap :p
Same Error for me...
In some other lua files it works well!
Any fix?
What do you mean by "in some other lua files it works well?"
How about this, that's my code, you stole it without my permission, so why should we help you?
[QUOTE=Ruzza;38260274]How about this, that's my code, you stole it without my permission, so why should we help you?[/QUOTE]
Actually he didn't steal that code, it is public on pastebin.
Fixed it...
1. The Method is Server-Side, you umsg is useless, i think
Make a concommand
let the client run this command
go through all Players and see, if he is VIP (!!ServerSide!!)
send a umsg to the client
there you go
[QUOTE=Jayden;38260309]Actually he didn't steal that code, it is public on pastebin.[/QUOTE]
Please post me a link to my own code being put on pastebin.
Just realized this was leaked ages ago.
Pretty much if you want to fix this, you need _R.Player.IsVIP to be a function to return true/false if a player is VIP or not.
[lua]
local _R = debug.getregistry()
function _R.Player:IsVIP()
return self:GetNWBool( "isvip", false )
end[/lua]
Make sure to set player:SetNWBool( "isvip", true ) on serverside.
Sorry, you need to Log In to post a reply to this thread.