Justn Posted November 16, 2011 Author Share Posted November 16, 2011 I thought this was pretty cool and I'm using a modified version of this for my project. If a player is killed he has a 25 out of 100 chance (kinda) he will drop a piece of his equipment.This is a simple code and can easily be modified for a variety of things including penalty for pks and dropping multiple items instead of just one. **Increase** the 'Rate' to **decrease** **the chance** and **decrease** the 'Rate' to **increase the chance**. All credits go to Richy for this piece of code. Everything is in Sub OnDeath in modplayer server-side.**Server****modPlayer:****Find:**```Sub OnDeath(ByVal Index As Long)```**Under it add:**```Dim Rate As Long Dim DropNum As Long```**Next find:**```' Drop all worn items For i = 1 To Equipment.Equipment_Count - 1 If GetPlayerEquipment(Index, i) > 0 Then PlayerMapDropItem Index, GetPlayerEquipment(Index, i), 0 End If Next```**And Replace it with this:**```Rate = 75 If Rand(1, 100) >= Rate Then DropNum = Rand(1, 4) Select Case DropNum Case 1 If GetPlayerEquipment(index, Weapon) > 0 Then PlayerMapDropItem index, GetPlayerEquipment(index, Weapon), 0 End If GiveInvItem index, GetPlayerEquipment(index, Weapon), 0 SetPlayerEquipment index, 0, Weapon Case 2 If GetPlayerEquipment(index, Helmet) > 0 Then PlayerMapDropItem index, GetPlayerEquipment(index, Helmet), 0 End If GiveInvItem index, GetPlayerEquipment(index, Helmet), 0 SetPlayerEquipment index, 0, Helmet Case 3 If GetPlayerEquipment(index, Armor) > 0 Then PlayerMapDropItem index, GetPlayerEquipment(index, Armor), 0 End If GiveInvItem index, GetPlayerEquipment(index, Armor), 0 SetPlayerEquipment index, 0, Armor Case 4 If GetPlayerEquipment(index, Shield) > 0 Then PlayerMapDropItem index, GetPlayerEquipment(index, Shield), 0 End If GiveInvItem index, GetPlayerEquipment(index, Shield), 0 SetPlayerEquipment index, 0, Shield End Select End If Rate = 90 If Rand(1, 100) >= Rate Then For i = 1 To MAX_INV If Item(i).Type <> ITEM_TYPE_CURRENCY Then PlayerMapDropItem index, i, GetPlayerInvItemValue(index, i) End If Next End If```That's all its pretty simple. The random is pretty random so its not really 25 out of 100 every time. Would be nice to make it a % chance instead =p Link to comment Share on other sites More sharing options...
Mr.LLoyd Posted November 16, 2011 Share Posted November 16, 2011 good to have for a PvP ;] Link to comment Share on other sites More sharing options...
Fragment Posted November 17, 2011 Share Posted November 17, 2011 Thanks for this short, sweet and useful piece of code. Very good base for a custom pvp/pk system Link to comment Share on other sites More sharing options...
abhi2011 Posted March 16, 2012 Share Posted March 16, 2012 Hmmn shuldn't it be Mod Player??? Link to comment Share on other sites More sharing options...
Justn Posted March 16, 2012 Author Share Posted March 16, 2012 @abhi2011:> Hmmn shuldn't it be Mod Player???yep ;) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now