I don't want to create two separate topics, so here are two questions.
The first is about an OnPlayerAttack:
The question is why the hit.hasDamage is false? Or how can I edit hit info by other way?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 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.
Solved Decreasing player's damage
Discussion in 'Rust Development' started by master_clown, Jan 13, 2016.
-
Calytic Community Admin Community Mod
To check if any damage was actually done, you could try this..
Code:if(hitInfo.damageTypes.Total > 0)
Code:DamageType dt = hitInfo.damageTypes.GetMajorityDamageType(); if (dt == DamageType.Bullet) //..
Code:hitInfo.damageTypes.Scale(DamageType.Bullet, 0.3f);hitInfo.damageTypes.ScaleAll(0.3f);
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; }
-
Alright, rhanks
-
-
0.3 = 30%
1.0 = 100% (normal)
2.5 = 250%
etc -