Prop team have player models equipped - causes inability to become a prop
16 replies, posted
So quite simply,
For some reason, when a player is on the props team, if they had a player model equipped while on the hunter team, they will keep it equipped whilst a prop unless they manually take precious seconds from hiding by opening the pointshop and holstering the player model.
The real issue is that the camera seems to be above the player's head when this is occuring, which causes the inability to choose a prop, at first I noticed if you press control or spam control you are able to select a prop however this is really rare after much testing.
After looking into all the files, applying the code found here: Pointshop
And manually reinstalling pointshop, nothing fixed it, the player model was not allowed to be equipped as a prop but still would not force a holster, attempting to write anything to force a holster would just take the player model off the listings.
I would appreciate any guidance, I am very new to Lua, and tried seeking the answer prior to asking!
Cheers
Can you post exactly what code you are using and where you are putting it.
So if I put this in the lua for each player model, it doesn't allow them to equip the player model, but if it is already equipped, it stays equipped as expected:
function ITEM:CanPlayerEquip(ply)return ply:Team() != 2end
https://files.facepunch.com/forum/upload/460380/18d52deb-a2ce-4199-a43c-c61504f5bd8a/image.png so as you can see in this one, the halo around the prop isnt appearing until I press control in this one:
https://files.facepunch.com/forum/upload/460380/0217f96a-11fe-4118-9136-095a419ffd26/image.png
If I spam click and control it will eventually work however until I do this:
https://files.facepunch.com/forum/upload/460380/9fe5bb5c-2ed3-4db9-a358-2b7a5ce123e3/image.png
I will have difficulty, on other servers they seem to have forced props to have the models holstered, and if you try to equip it will say something like "you cannot do that right now" which is probably a variant of this
function ITEM:CanPlayerEquip(ply)return ply:Team() != 2end
Don't use ENUMS as numbers. Use their enum-names
Would you be able to give me an example?
Many thanks!
TEAM_CITIZEN, TEAM_POLICE. I don't know them exactly.
You can also do team.GetName(ply:Team()) != "team name"
No, Player/Team returns the number corresponding to the ENUM, in fact I am sure ENUM's are for reference and numbers should always be used
Keep the ITEM:CanPlayerEquip on the restricted items so they cannot equip during rounds.
Add this to the restricted items files too and it should work: ([Lua] function ITEM)
function ITEM:PlayerSpawn(ply)
if (ply:Team() != 2) then
ply:PS_HolsterItem(self.ID)
ply:PS_Notify(self.Name .. " was holstered due to your current team!")
end
end
This will not automatically re-equip the item but will notify the user so they are aware. An automatic system can be made using the same PS_HolsterItem function. More information can be found Home | PointShop Documentation for Garry's Mod
Thank you so much, it sounds really tricky but I hope it isn't!
I will let you know if it is successful!
Not exactly sure if you fixed it because my answer is marked as accepted but I'd suggest a simple server restart to re-load the items and their data as this is working fine on my server.
I'll double check, I restart pretty much all the time when I change something
Yea, thats odd. Try adding a simple print inside the ITEM:PlayerSpawn to see if that is actually running when a player spawns.
Forgive me if I am dumb here haha
function ITEM:CanPlayerEquip(ply)return ply:Team() != 2endfunction ITEM:PlayerSpawn(ply) print
if (ply:Team() != 2) then
ply:PS_HolsterItem(self.ID)
ply:PS_Notify(self.Name .. " was holstered due to your current team!")
endend
function ITEM:CanPlayerEquip(ply)
return ply:Team() != 2
end
function ITEM:PlayerSpawn(ply)
print("Player Spawn Test")
if (ply:Team() != 2) then
ply:PS_HolsterItem(self.ID)
ply:PS_Notify(self.Name .. " was holstered due to your current team!")
end
end
Change the code to this and then test it again. After testing tell me if it prints that message in server console.
Hmm that just seemed to unlist the PM from the shop:
ITEM.Name = 'EVE'
ITEM.Price = 0
ITEM.Model = 'models/player/pyroteknik/eva.mdl'
ITEM.AllowedUserGroups= { "superadmin" }
function ITEM:OnEquip(ply, modifications)
if not ply._OldModel then
ply._OldModel = ply:GetModel()
end
timer.Simple(1, function() ply:SetModel(self.Model) end)
end
function ITEM:OnHolster(ply)
if ply._OldModel then
ply:SetModel(ply._OldModel)
end
end
function ITEM:PlayerSetModel(ply)
ply:SetModel(self.Model)
end
function ITEM:CanPlayerEquip(ply)return ply:Team() != 2endfunction ITEM:PlayerSpawn(ply)print("Player Spawn Test")
if (ply:Team() != 2) then
ply:PS_HolsterItem(self.ID)
ply:PS_Notify(self.Name .. " was holstered due to your current team!")
endend
Scratch that Josh, that's done it!
Not sure what I did but I fiddled with the spacing in the Lua and its done it!
https://files.facepunch.com/forum/upload/460380/c320dcaf-e1cd-477b-9ecd-d7bc7eb2a0a1/image.png
I am just glad the fix is there, ideally I would love to figure out how to save the items holstered and have them re-equipped after but for now, that is more than enough, cheers!
Good to hear thats likely due to facepunch forums formatting it wrong in code tags
Sorry, you need to Log In to post a reply to this thread.