get a player's prop count

I cant get it to work .

[lua] ply:GetCount( “props” ) [/lua]

I tried using it today and it stays at -1 every time I spawn a prop.

[lua]
hook.Add( “PlayerSpawnProp”, “PropLimit”, function(ply)
–print(ply:GetCount(“props”))
–print(ply:EV_GetRank())

    if ply:GetCount( "props" ) >= 200 and ply:EV_GetRank() == "superadmin" then
    ply:ChatPrint("You've hit the Prop Limit")
    return false
elseif ply:GetCount( "props" ) >= 200 and ply:EV_GetRank() == "admin" then
    ply:ChatPrint("You've hit the Prop Limit")
    return false
elseif ply:GetCount( "props" ) >= 160 and ply:EV_GetRank() == "respected" then
    ply:ChatPrint("You've hit the Prop Limit")
    return false
elseif ply:GetCount( "props" ) >= 100 and ply:EV_GetRank() == "guest" then
    ply:ChatPrint("You've hit the Prop Limit")
    return false
end

end)

[/lua]
any help please??

Here’s some old code I made for prop groups with ULX. It shouldn’t be hard for you to change it around to be compatible with evolve.

[lua]
–[[---------------------------------------------------------
Name: LimitReachedProcess
-----------------------------------------------------------]]
local PropGroupMax = {
[“vip”] = 50,
[“admin”] = 60,
[“superadmin”] = 100
}

local function LimitReachedProcess(ply, str)
if (game.SinglePlayer()) then return true end
if (!IsValid(ply)) then return true end
local c = PropGroupMax[ply:GetUserGroup()]
if !c then
c = cvars.Number(“sbox_max”…str, 0)
end
if (ply:GetCount(str) < c or c < 0) then return true end
ply:LimitHit(str)
return false
end

–[[---------------------------------------------------------
Name: gamemode:PlayerSpawnProp( ply, model )
Desc: Return true if it’s allowed
-----------------------------------------------------------]]
function GM:PlayerSpawnProp(ply, model)
return LimitReachedProcess(ply, “props”)
end
[/lua]

Well thanks but my problem is with ply:GetCount which is on your code. that would put me back to square one no? :frowning:

-snip-

This is probably the wrong way to go about it seeing as it’s already built into the game but you could just



function propnum( ply, mdl )
    local nprops = ply.propnum or 0
        nprops = nprops + 1 
        if nprops >= 200 and ply:EV_GetRank() == "superadmin" then
        ply:ChatPrint("You've hit the Prop Limit")
        return false
    elseif nprops >= 200 and ply:EV_GetRank() == "admin" then
        ply:ChatPrint("You've hit the Prop Limit")
        return false
    elseif nprops >= 160 and ply:EV_GetRank() == "respected" then
        ply:ChatPrint("You've hit the Prop Limit")
        return false
    elseif nprops >= 100 and ply:EV_GetRank() == "guest" then
        ply:ChatPrint("You've hit the Prop Limit")
        return false
    end
end
hook.Add( "PlayerSpawnProp", "propnum", propnum )



gotta define dat ply.propnum if it gives you issues.
also have to go about removing props and so on so yeah, stick with what you’ve got and sort your GetCount