1. Post #1
    Gold Member
    PaellaPablo's Avatar
    May 2011
    132 Posts
    The title is rather self explanitory.

    Being new to lua, I've already learned SQL integration, as well as DERMA and all that nonsense.

    Now what I need to know, is how am I going to make a 'hat' (so to speak), parent to a player when they spawn.



    Scenario:
    Suggest a player has 'melon' as his NWString for HAT, and I want then to equip him with a Melon hat when he spawns, how will I do that.

    (I do understand how to integrate the table and the NW string to directly relate the MDL file.


    If someone could point me in the right direction (wiki links would be awesome), or provide code snippets (even better!), It would be HIGHLY appreciated.


    Thanks,
    Paella Pablo

  2. Post #2
    KatNotDinner's Avatar
    June 2011
    768 Posts
    You should create an entity (probably a custom one that is light on the server so you can have like 50 hats without affecting performance) uisng ents.Create (entity_name).
    Then you shold set the desired model, set it's angles to the player's angles using SetAngles() then set it's position to the head position (there was some way to get bone positions but I can't remember what it was right now). After that do myentity:SetParent(player) and you are done.
    I heard that the best way to do this is using scripted effects but I have no idea how to create one sadly.
    Reply With Quote Edit / Delete Reply Windows 7 Greece Show Events Disagree Disagree x 1 (list)

  3. Post #3
    Gold Member
    -TB-'s Avatar
    August 2008
    1,383 Posts
    local ply = player.GetAll()[1]
    local pos, ang = ply:GetBonePosition(10)
    local hat = ents.Create("prop_physics")
    hat:SetModel("models/props_junk/watermelon01.mdl")
    hat:SetPos(pos)
    hat:Spawn()
    hat:SetParent(ply)
    hat:SetParentPhysNum(10)
    
    This might work. No need for tables or NWStrings. Use http://maurits.tv/data/garrysmod/wik...index51e9.html and CTRL F and search for common sense words of what you want to do.

  4. Post #4
    Gold Member
    PaellaPablo's Avatar
    May 2011
    132 Posts
    I meant the string would be referenced from an SQLite database, as that is where the pointstore loadouts are saved.


    If I could ask one more question:

    If I wanted to modify the angle, how would I do that.

    Needless to say, thank you very much.

  5. Post #5
    jrj996's Avatar
    July 2009
    1,629 Posts
    I meant the string would be referenced from an SQLite database, as that is where the pointstore loadouts are saved.


    If I could ask one more question:

    If I wanted to modify the angle, how would I do that.

    Needless to say, thank you very much.
    ang + Angle(0,0,0)
    
    ?

  6. Post #6
    Gold Member
    PaellaPablo's Avatar
    May 2011
    132 Posts
    So,

    hat:SetAngle(ang) before parenting it?
    Reply With Quote Edit / Delete Reply Windows 7 Australia Show Events Agree Agree x 1 (list)