1. Post #1
    SharpCoder's Avatar
    February 2012
    59 Posts
    Hello,

    I am trying to spawn a non-player object (I have tried both npc_citizen and prop_physics), and the goal is to force it into an animation. For my specific purposes, I need the object (which happens to be a player/npc model) to enter the "sitchair1" animation (which I know the model in question has).

    Question
    How can I spawn an object of type (NPC/prop_physics), adorned with a player/NPC model, and forced into an animation? Here is a code snippet of what I am currently trying to use. It may be useful to note that, no matter what I do, the NPC (when I tried this with entity type: npc_citizen), just stands around instead of entering an animation.

    LUA Snippet
    local npcModel = ents.Create("npc_citizen")
    npcModel:SetPos(npcModelPos);
    npcModel:Spawn();
    npcModel:SetModel("models/humans/suits2/male_09.mdl");	
    local sit = npcModel:LookupSequence("sitchair1") or npcModel:LookupSequence("headcrabbed");
    if ( sit == nil or sit <= 0 ) then	print("Didn't find animation");   else   print("Found animation!"); end
    npcModel:SetSequence( sit );
    

    Thank you for your time, I appreciate any suggestions!

  2. Post #2
    ASK ME ABOUT MY SAM 6420 FETISH
    ArmageddonScr's Avatar
    July 2011
    691 Posts
    In my testing I haven't gotten SetSequence to work serverside, try running it on the client if you haven't
    Reply With Quote Edit / Delete Reply Windows XP United States Show Events Winner Winner x 1 (list)

  3. Post #3
    SharpCoder's Avatar
    February 2012
    59 Posts
    In my testing I haven't gotten SetSequence to work serverside, try running it on the client if you haven't
    :D

    Well damn... That certainly fixed it! :D Thank you so much. I spent way longer than I should have trying to get that working. Thank you!!!!!!
    Reply With Quote Edit / Delete Reply Windows 7 United States Show Events Friendly Friendly x 1 (list)

  4. Post #4
    Can someone give me a dayz copy?
    gonzalolog's Avatar
    April 2011
    1,191 Posts
    So...it works only on clientside???
    Reply With Quote Edit / Delete Reply Windows 7 Argentina Show Events Dumb Dumb x 1 (list)

  5. Post #5
    SharpCoder's Avatar
    February 2012
    59 Posts
    So...it works only on clientside???
    Yessir.

    What I ended up doing was making a client side concommand that searches for my specific entity model and forces it into an animation. When needed, I have the server call this concommand on the specific player(s) though you could design any number of other ways to accomplish this.

  6. Post #6
    ASK ME ABOUT MY SAM 6420 FETISH
    ArmageddonScr's Avatar
    July 2011
    691 Posts
    A more professional way to do that would be usermessages
    Reply With Quote Edit / Delete Reply Windows XP United States Show Events Agree Agree x 1 (list)

  7. Post #7
    SharpCoder's Avatar
    February 2012
    59 Posts
    A more professional way to do that would be usermessages
    Yeah that is far more elegant. In fact, I tried doing that at first but my target-entity was becoming nullified somehow when I attempted to pass it through a usermessage. I thought it might be due to the fact that the entity was created server-side, and thus the reference was not applicable client side. I haven't worked extensively with complex objects via: usermessages though, so I am not entirely sure what the issue was.

  8. Post #8
    ASK ME ABOUT MY SAM 6420 FETISH
    ArmageddonScr's Avatar
    July 2011
    691 Posts
    I'm 80% sure it was because the client didn't know the entity existed yet. Creating a timer.Simple(0 would have fixed it
    Reply With Quote Edit / Delete Reply Windows XP United States Show Events Agree Agree x 1 (list)