1. I don't want to create two separate topics, so here are two questions.

    The first is about an OnPlayerAttack:
    Code:
    [HookMethod("OnPlayerAttack")] 
    object OnPlayerAttack(BasePlayer attacker, HitInfo hit) 
    { 
    if (hit.HitEntity is BasePlayer) 
    { BasePlayer vict = hit.HitEntity as BasePlayer; // the plugin decreases the damage for friends. 
    if (!friends.ContainsKey(attacker.userID) || 
    !friends[attacker.userID].friends.ContainsKey(vict.userID)) 
    return null; // I know the func doesn't end above, but hit.hasDamage is false always 
    SendReply(attacker, hit.hasDamage.ToString()); 
    if(hit.hasDamage) { 
    hit.damageTypes.types[(int)DamageType.Bullet] = 
    hit.damageTypes.types[(int)DamageType.Bullet] * 0.3f; 
    // .... 
    } 
    } 
    return null; 
    }
    The question is why the hit.hasDamage is false? Or how can I edit hit info by other way?

    The second is about an OnCupboardAuthorize hook. How should I get and work with priviledge.authorizedPlayers? For instance I wanna get the list of userIDs of authorized players.
     
  2. Calytic

    Calytic Community Admin Community Mod

    No idea.

    To check if any damage was actually done, you could try this..
    Code:
    if(hitInfo.damageTypes.Total > 0)
    To check if majority bullet damage was done
    Code:
    DamageType dt = hitInfo.damageTypes.GetMajorityDamageType();
    if (dt == DamageType.Bullet) //..
    To change damage, use the Scale or ScaleAll methods
    Code:
    hitInfo.damageTypes.Scale(DamageType.Bullet, 0.3f);hitInfo.damageTypes.ScaleAll(0.3f);
    [DOUBLEPOST=1452733525][/DOUBLEPOST]
    This is untested but something to this effect is what you're looking for..
    Code:
    private List<string> GetToolCupboardUserIDs(BuildingPrivlidge cupboard)
    {
        List<string> userIDs = new List<string>();    foreach (ProtoBuf.PlayerNameID pnid in cupboard.authorizedPlayers)
        {
            userIDs.Add(pnid.userid.ToString());
        }    return userIDs;
    }
     
  3. Alright, rhanks
     
  4. What exactly does this do to the amount of damage? the '0.3f'.
     
  5. 0.3 = 30%
    1.0 = 100% (normal)
    2.5 = 250%
    etc
     
  6. Thanks!