Yeah so i implemented that if a player dies in a certain pvp area, he looses 1 item or more items. I programmed it so he drops it on death.

problem is i cant figure out to make the actually killer (attacker) see the drops. it just appears after the set period of time for everyone instead for only the attacker.

I know where the code is to make it right, but i dont got the knowledge to change it for this matter… 😕


Function CanPlayerPickupItem(ByVal index As Long, ByVal mapItemNum As Long)

Dim mapnum As Long

    mapnum = GetPlayerMap(index)

    ' no lock or locked to player?

    If MapItem(mapnum, mapItemNum).playerName = vbNullString Or MapItem(mapnum, mapItemNum).playerName = Trim$(GetPlayerName(index)) Then

	    CanPlayerPickupItem = True

	    Exit Function

    End If

    CanPlayerPickupItem = False

End Function

So it seems that by default no goods are dropped. (The sub u posted is wrong. It just checks if the given item on the ground can be looted. All items are visible to everyone by default I believe.)

So first of we have to actual check whether the player is dead or alive. To do this go to the PlayerAttackPlayer sub. This sub handles the actual damage dealing and checking whether the player is dead.

In this sub there is a if statement that checks whether the damage dealt is greater than that of the players current Hp. This means death. So within this check there are normal statements that shout out to everyone that the attack player is a Pker. And exp is handled out.

Now this is where we add our code. It is quite simple. Loop through the victim players inventory (and equipment) and drop all the stuff. You can do this by looping the players inventory and getting the item num and spawning that item (SpawnItem) at the victim’s coords (x,y). After that the players inventory has to be cleared though. So after the item is spawned just remove that item. This can be done by setting the ItemNum of the slot in the inventory and the value to 0.

But this makes the items visible to everyone. In the MapItemRec add a variable that indicated the time in which the item should be visible to everyone. (Use GetTickCount + <the time="" the="" item="" should="" be="" visible="" to="" that="" player="" only="">) Also add a variable indicating which player the item should be dropped for. Then before the MapItemUpdate packet is sent out to everybody check whether it has a player whom only can see that item. If so then SendAnotherPacket send only to that player.

Now after the fixed time the item should be visible to everyone. To do that in the server loop make a check that checks whether the current tick is > than the value assigned to item. If so then make the item visible to everyone by sending the packet to everyone. And reset the timer and the Player Index.

If you need more help or didn’t understand a certain part, PM me or post below.

P.S I believe there is a sub that handles PlayerDroppingItems. That sub can be used.</the>

resolved? response in 2 days otherwise i’ll set it ^.^

Sec ill check it out :) didnt think someone posts in 1 hour and i fell in deep work whit my game.

So, Yeah i made something like this in PlayerAttackPlayer before i asked the question here :)

If Map(GetPlayerMap(attacker)).Moral = MAP_MORAL_DEADLY Then ' might change the (attacker) here to (victim) because the victim dies here ![:)](<#EMO_DIR#>/smile.png)

		 mapnum = GetPlayerMap(attacker)

		 For i = 1 To MAX_INV

			 PlayerMapDropItem (victim), i, 99


		 For i = 1 To 4

			 PlayerUnequipItem (victim), i


		 For i = 1 To MAX_INV

			 PlayerMapDropItem (victim), i, 99


	 End If

This happns right after the expriencedrop.

then i added the variable now:

Private Type MapItemRec

itemdroptime As Long

itemdroptime = GetTickCount + 60000 ' which should be 1 min? or is 1 tickcount 1 sec alrdy?

playerattackplayerdrop As Long '<- the variable indicating who got the drop right?

but i dont really get the rest of the itemupdate packets :) but i am here to learn about this. sorry for the trouble.



why disregard?^^

why disregard?^^

Its uncompleted. Can never save. My posts are always lost.

So yeah this problem is still unsolved, if anybody wants to contribute a good idea, i´d be glad

Log in to reply