• How do i set prop limit per player?
    36 replies, posted
[code]local pMeta = FindMetaTable("Player") //Define metatable for players pMeta.OldGetCount = pMeta.GetCount //Backup original getcount as we will be using it later function pMeta:GetCount( str ) //Making function if self:IsSuperAdmin() then //Change this to if steamid or anything to define the player return self:OldGetCount() - 10 //Change the number to minus off = increase limits //return 0 //Uncomment this and remove the line above to have no limits at all else return self:OldGetCount() //Other than those defined they will have the original limit end end[/code] [url]http://wiki.garrysmod.com/?title=Player.GetCount[/url]
Ok how do i apply it to this script XD [code] -- Assmod Ranks local proplim = {} proplim[0] = 5 -- Owner proplim[1] = 75 -- SuperAdmin proplim[2] = 50 -- Admin proplim[3] = 40 -- TempAdmin proplim[4] = 30 -- Operator proplim[5] = 25 -- GoldDonator proplim[6] = 20 -- SilverDonator proplim[7] = 15 -- Respected proplim[10] = 10 -- Guest proplim[255] = 0 -- Banned hook.Add("PlayerSpawnProp","PropLimit",function(ply) local p = ply.props or 0 if p == proplim[ply:GetLevel()] then ply:ChatPrint("You hit the limit of "..proplim[ply:GetLevel()].." props!") return false else ply.props = p + 1 return true end end) hook.Add("PlayerSpawnedProp", "SetOwner", function(ply,m,e) e.LimitOwner = ply ply:ChatPrint("You can spawn " .. proplim[ply:GetLevel()] - ply.props .. " more props.") end) hook.Add("EntityRemoved", "RemoveIt", function(e) Msg("\n Something was removed "..e:GetClass().."\n") if not e:GetClass() == "prop_physics" then return end if not e.LimitOwner then return end local o = e.LimitOwner o.props = o.props - 1 print("[DEV] "..o.props.." & removed.") end) [/code]
[code] -- Assmod Ranks local proplim = {} proplim[0] = 1000 -- Owner proplim[1] = 75 -- SuperAdmin proplim[2] = 50 -- Admin proplim[3] = 40 -- TempAdmin proplim[4] = 30 -- Operator proplim[5] = 25 -- GoldDonator proplim[6] = 20 -- SilverDonator proplim[7] = 15 -- Respected proplim[10] = 10 -- Guest proplim[255] = 0 -- Banned local pMeta = FindMetaTable("Player") pMeta.OldGetCount = pMeta.GetCount function pMeta:GetCount( str ) if string.lower(str) == "props" then if self:IsSuperAdmin() then return self:OldGetCount(str) - proplim[self:GetLevel()] else return self:OldGetCount(str) end end end[/code] Try this. Not tested
[code] if self:IsSuperAdmin() then return self:OldGetCount(str) - proplim[self:GetLevel()] else return self:OldGetCount(str) [/code] Why does superadmin have proplim[self:GetLevel(). And non super not end
woops hold on [code] -- Assmod Ranks local proplim = {} proplim[0] = 1000 -- Owner proplim[1] = 75 -- SuperAdmin proplim[2] = 50 -- Admin proplim[3] = 40 -- TempAdmin proplim[4] = 30 -- Operator proplim[5] = 25 -- GoldDonator proplim[6] = 20 -- SilverDonator proplim[7] = 15 -- Respected proplim[10] = 10 -- Guest proplim[255] = 0 -- Banned local pMeta = FindMetaTable("Player") pMeta.OldGetCount = pMeta.GetCount function pMeta:GetCount( str ) if string.lower(str) == "props" then return self:OldGetCount(str) - proplim[self:GetLevel()] end return self:OldGetCount(str) end[/code]
[QUOTE=wesleydeman;28144923]I have it in garrysmod/lua/autorun/server/proplimit.lua everything is workin. Except the ent removed thing. [editline]19th February 2011[/editline] Ok come and test it on my server 94.75.251.55:27015 Your guest so prop limit would be 10 [editline]19th February 2011[/editline] Ok it works now a friend changed some code.[/QUOTE] Can you post the working code so I can learn from my error.
Nevermind its not working anymore -,- [editline]19th February 2011[/editline] [QUOTE=mrciku;28148792]woops hold on [code] -- Assmod Ranks local proplim = {} proplim[0] = 1000 -- Owner proplim[1] = 75 -- SuperAdmin proplim[2] = 50 -- Admin proplim[3] = 40 -- TempAdmin proplim[4] = 30 -- Operator proplim[5] = 25 -- GoldDonator proplim[6] = 20 -- SilverDonator proplim[7] = 15 -- Respected proplim[10] = 10 -- Guest proplim[255] = 0 -- Banned local pMeta = FindMetaTable("Player") pMeta.OldGetCount = pMeta.GetCount function pMeta:GetCount( str ) if string.lower(str) == "props" then return self:OldGetCount(str) - proplim[self:GetLevel()] end return self:OldGetCount(str) end[/code][/QUOTE] Dont work
Sorry, you need to Log In to post a reply to this thread.