I am attempting to disable the pointshop (Pointshop 3 by _Undefined) and holster all items if a player is on a specific team.
I am running a Zombie Survival server, and the team ID for the zombies is [B]TEAM_ZOMBIE[/B] with an id of [B]3[/B].
I have attempted the code below from this thread ([url]https://facepunch.com/showthread.php?t=1398459[/url])
[CODE]function ITEM:CanEquip( ply )
if ( ply:Team( ) == TEAM_ZOMBIE ) then
return false;
end
return true;
end[/CODE]
as well as the code from this thread ([url]https://facepunch.com/showthread.php?t=1328539[/url])
[CODE]function ITEM:CanPlayerEquip(ply)
return ply:Team() != 2
end[/CODE]
Both spit out the following error in the console, and remove the item from the pointshop for both teams:
[CODE]
[ERROR] addons/pointshop-master/lua/pointshop/items/headshatsmasks/texthat.lua:1: attempt to index global 'ITEM' (a nil value)
1. unknown - addons/pointshop-master/lua/pointshop/items/headshatsmasks/texthat.lua:1
[/CODE]
I am at a complete loss here, as I don't know what other code I should attempt to implement. Any help would be appreciated.
That's an update error. You can completely ignore it because it doesn't matter, once you load the module completely it'll work (And even if you just update it, and ignore the error)
Your code should work just fine, can even be shortened down to this: [lua]function ITEM:CanEquip( ply )
return ply:Team() ~= TEAM_ZOMBIE
end[/lua]
[QUOTE=JasonMan34;52117185]That's an update error. You can completely ignore it because it doesn't matter, once you load the module completely it'll work (And even if you just update it, and ignore the error)
Your code should work just fine, can even be shortened down to this: [lua]function ITEM:CanEquip( ply )
return ply:Team() ~= TEAM_ZOMBIE
end[/lua][/QUOTE]
So would loading a new map fix it? Or do I have to restart the whole server?
[QUOTE=hankster112;52124651]So would loading a new map fix it? Or do I have to restart the whole server?[/QUOTE]
You literally just need to update the file.
If you don't have auto refresh, change the map
It's still not working, hats still show up on zombies, even after adding your code to the item files and restarting the server.
Did you use CanEquip or CanPlayerEquip? Because CanEquip isn't a real function (Use the latter one)
[QUOTE=JasonMan34;52130264]Did you use CanEquip or CanPlayerEquip? Because CanEquip isn't a real function (Use the latter one)[/QUOTE]
I've changed it to CanPlayerEquip and the results are still the same.
I'm supposed to be adding it to the item's Lua file, right?
[QUOTE=hankster112;52136105]I've changed it to CanPlayerEquip and the results are still the same.
I'm supposed to be adding it to the item's Lua file, right?[/QUOTE]
Post the item file code
This is for the text hat.
[CODE]ITEM.Name = 'Text Hat'
ITEM.Price = 2000
ITEM.Model = 'models/extras/info_speech.mdl'
ITEM.NoPreview = true
local MaxTextLength = 16
function ITEM:PostPlayerDraw(ply, modifications, ply2)
if not ply == ply2 then return end
if not ply:Alive() then return end
if ply.IsSpec and ply:IsSpec() then return end
local offset = Vector(0, 0, 79)
local ang = LocalPlayer():EyeAngles()
local pos = ply:GetPos() + offset + ang:Up()
ang:RotateAroundAxis(ang:Forward(), 90)
ang:RotateAroundAxis(ang:Right(), 90)
cam.Start3D2D(pos, Angle(0, ang.y, 90), 0.1)
draw.DrawText(string.sub(modifications.text or ply:Nick(), 1, MaxTextLength), "PS_Heading", 2, 2, modifications.color or Color(255, 255, 255, 255), TEXT_ALIGN_CENTER)
cam.End3D2D()
end
function ITEM:Modify(modifications)
Derma_StringRequest("Text", "What text do you want your hat to say?", "", function(text)
if string.find(text, "#") then
text = string.gsub(text, "#", "")
end
modifications.text = string.sub(text, 1, MaxTextLength)
PS:ShowColorChooser(self, modifications)
end)
end
function ITEM:CanPlayerEquip( ply )
return ply:Team() ~= TEAM_ZOMBIE
end
[/CODE]
Anyone? Anyone at all?
CanPlayerEquip should work.
Add prints to make sure the code is running and that TEAM_ZOMBIE is defined, and check for any errors in the console
Could you be more specific? Because I have CanPlayerEquip in the code, and I'm sure TEAM_ZOMBIE is defined.
Sorry, you need to Log In to post a reply to this thread.