Well, this is called when the player is spawning props via Q menu
[url]https://wiki.garrysmod.com/page/SANDBOX/PlayerSpawnProp[/url]
It is all defined here:
[url]https://github.com/garrynewman/garrysmod/blob/master/garrysmod/gamemodes/sandbox/gamemode/player.lua[/url]
Call [48] function GM:PlayerSpawnProp( ply, model )
Call [24] local function LimitReachedProcess( ply, str )
Call [28] ply:CheckLimit( str )
Which is: [url]https://wiki.garrysmod.com/page/Player/CheckLimit[/url]
I already tried:
Ply:CheckLimit("props")
Entity:SetPlayer(Ply) --> Gives attempt to call a nil value, though it works on sents
Ply:AddCount("props")
My Entity creator is defined here:
[url]https://github.com/dvdvideo1234/TrackAssemblyTool/blob/master/lua/trackassembly/trackasmlib.lua[/url]
function MakePiece(sModel,vPos,aAng,nMass,sBgSkIDs,clColor)
What am I doing wrong forum ??
Entity->SetOwner
[QUOTE=code_gs;50400353]Entity->SetOwner[/QUOTE]
but if you're using this for props, as OP wants, SetOwner is used for projectiles and things that should have physics attackers, which in turn disables collision between the entity and its owner.
If you want to add it to their undo list
[lua]
undo.Create("Prop")
undo.AddEntity(entityObject)
undo.SetPlayer(player)
undo.Finish()
[/lua]
[QUOTE=Z0mb1n3;50400376]but if you're using this for props, as OP wants, SetOwner is used for projectiles and things that should have physics attackers, which in turn disables collision between the entity and its owner.
If you want to add it to their undo list
[lua]
undo.Create("Prop")
undo.AddEntity(entityObject)
undo.SetPlayer(player)
undo.Finish()
[/lua][/QUOTE]
Yes, that's correct, this part works perfectly, but this is not the thing that I am trying to do.
[url]https://steamcommunity.com/sharedfiles/filedetails/?id=557962280[/url]
When I spawn a track ( entity ), the player holding the tool does not take the ownership:
Owner: N/A
Class: prop_phisics
As you see in the above example the ULX is saying that I do not own the prop being spawned via "asmlib.MakePiece".
However, when I use the Q menu to spawn something it says:
Owner: [BA][Sk$Bh]Trick or treat KID!
Maybe I should remove the [lua] ePiece:Activate() [/lua] as it is used for activating sents..
May be something like this .... from [url]https://github.com/garrynewman/garrysmod/blob/master/garrysmod/gamemodes/sandbox/gamemode/commands.lua[/url]
[lua]
-- Tell the gamemode we just spawned something
if ( IsValid( Player ) ) then
gamemode.Call( "PlayerSpawnedProp", Player, Model, Prop )
end
[/lua]
Since MOST prop protections use CPPI you could just call CPPISetOwner(player)
[QUOTE=LUModder;50401820]Since MOST prop protections use CPPI you could just call CPPISetOwner(player)[/QUOTE]
Thanks, I will be sure to check it out, though have to see if the library is available first ;)
[QUOTE=LUModder;50401820]Since MOST prop protections use CPPI you could just call CPPISetOwner(player)[/QUOTE]
It turns out it will work when you do this in the flowing order:
[lua]
local sLimit = GetOpVar("CVAR_LIMITNAME") -- = "asmtracks"
if(not pPly:CheckLimit(sLimit)) then -- Returns false if the limit is hit
return StatusLog(nil,"MakePiece: Track limit reached") end
pPly:AddCount (sLimit , ePiece)
pPly:AddCount ("props", ePiece)
pPly:AddCleanup(sLimit , ePiece)
pPly:AddCleanup("props", ePiece)
[/lua]
Where the method "AddCleanup" if commented the owner is "N/A"
10x all, I guess I do not have to use CPPISetOwner.
Thought Now I have different problem.
The prop created is not added into the clean-up menu. I am using:
[url]https://github.com/dvdvideo1234/TrackAssemblyTool/blob/master/lua/weapons/gmod_tool/stools/trackassembly.lua[/url]
[lua]
if(CLIENT) then --
languageAdd("Cleanup_trackassemblies", "Clean all trackassembly pieces") --<<-- These two
languageAdd("Cleaned_trackassemblies", "Clean all trackassembly pieces")
-- languageAdd("cleanup."..asmlib.GetOpVar("CVAR_LIMITNAME"), "Clean all trackassembly pieces") --<<-- Or these two
-- languageAdd("cleaned."..asmlib.GetOpVar("CVAR_LIMITNAME"), "Clean all trackassembly pieces")
end
if(SERVER) then
cleanupRegister(asmlib.GetOpVar("CVAR_LIMITNAME"))
end
[/lua]
Which of these two is actually the right way to do this, for my prop to be added into the "CleanUp" buttons with "Clean all trackassembly pieces" ( for example )
Under the "CleanUp" --> "Props" it clear perfectly
Edit: This should be both client and server side to be working like that !
[lua]
cleanupRegister(asmlib.GetOpVar("CVAR_LIMITNAME"))
[/lua]
Sorry, you need to Log In to post a reply to this thread.