;AMMO SCRIPT

If HasItem(#USERID,#TARGETID)=1

TakeItem(#USERID,#TARGETID)

If GetUserFlag(#USERID,22)>0
	If GetUserFlag(#USERID,22)<>GetItemFlag2(#TARGETID)
		If GetUserFlag(#USERID,22)<>GetItemFlag3(#TARGETID)
			If GetUserFlag(#USERID,23)>0
				SendMessageToUser(#USERID,"You lost "+GetUserFlag(#USERID,23)+" rounds of ammo for the "+GetItemName(GetUserFlag(#USERID,22))+" from loading "+GetItemName(#TARGETID)+"!", #MSG_CRITICAL)
				SetUserFlag(#USERID,23,0)
				SetUserFlag(#USERID,27,0)
			Endif
		Endif
	Endif
Endif

SendCombatMessage(#USERID,"You loaded "+GetItemFlag1(#TARGETID)+" rounds of "+GetItemName(#TARGETID)+" ("+Floor(GetUserFlag(#USERID,23)+GetItemFlag1(#TARGETID))+") ")
;SendCombatMessage(#USERID,""+GetItemName(#TARGETID)+" is used with the "+GetItemName(GetItemFlag2(#TARGETID))+" ")

SetUserFlag(#USERID,22,GetItemFlag2(#TARGETID))
SetUserFlag(#USERID,26,GetItemFlag3(#TARGETID))

If GetUserFlag(#USERID,27)=0
	SetUserFlag(#USERID,27,GetItemFlag4(#TARGETID))
Elseif GetUserFlag(#USERID,27)>GetItemFlag4(#TARGETID)
	SetUserFlag(#USERID,27,GetItemFlag4(#TARGETID))
Endif

SetUserFlag(#USERID,23,GetUserFlag(#USERID,23)+GetItemFlag1(#TARGETID))

Endif

Continue = 1
