I tried this code out for a model for someone's steam id:
[CODE]ITEM.Name = 'Tyrael'
ITEM.Price = 10000
ITEM.Model = 'models/player/tyrael/tyrael.mdl'
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 GM:PlayerSetModel(ply)
local mdl = GAMEMODE.playermodel or "models/player/tyrael/tyrael.mdl";
if ply:SteamID() == "STEAM_0:1:1810974" then
mdl = "models/player/tyrael/tyrael.mdl";
end
util.PrecacheModel(mdl)
ply:SetModel(mdl)
end[/CODE]
And I got this error. (I know the name for the file is weird but thats just cause i wanted to test it really fast). Can anyone help me with this?
[CODE][ERROR] addons/pointshop-master/lua/items/playermodels/adsfljadfj.lua:19: attempt to index global 'GM' (a nil value)
1. unknown - addons/pointshop-master/lua/items/playermodels/adsfljadfj.lua:19
2. include - [C]:-1
3. LoadItems - addons/pointshop-master/lua/sh_pointshop.lua:105
4. unknown - addons/pointshop-master/lua/autorun/pointshop.lua:35
[/CODE]
--EDIT-- Nvm
Use [URL="http://wiki.garrysmod.com/page/hook/Add"]hook.Add[/URL]
where do i put that?
[LUA]
function GM:PlayerSetModel(ply)
[/LUA]
->
[LUA]
function ITEM:PlayerSetModel(ply)
[/LUA]
Oh right. Thanks rejax! But There is still a problem. Everyone can still see and buy the model it doesn't check the ID. Any ideas?
Just check the SteamID and return false for any other SteamID.
Just this?
[CODE]if ply:SteamID() == "STEAM_0:1:1810974" then
mdl = "models/player/tyrael/tyrael.mdl";
end[/CODE]
I'm failing to see what you're trying to do
Is the model meant to be limited so that only a certain player can use it?
If so you should be using this function that's used by Pointshop
Of course replace the alive check with your steamid check
[quote]
Function: CanPlayerBuy
Arguments: ply (Player)
Realm: Server
Required: No
Description: Called when the player tries to buy the item. Return true or false.
Example:
function ITEM:CanPlayerBuy(ply)
return ply:Alive() -- only if alive
end
[/quote]
This still didn't work, unless I did it wrong lol
[CODE]function ITEM:CanPlayerBuy(ply)
return ply:SteamID() == "STEAM_0:1:1810974"
end[/CODE]
Sorry, you need to Log In to post a reply to this thread.