# Trace x2

**URL:** <https://forum.kirupa.com/t/trace-x2/331648>\
**Category:** Uncategorized\
**Created:** [September 17, 2013, 1:22pm UTC](https://forum.kirupa.com/t/trace-x2/331648 "2013-09-17T13:22:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dasLuft](https://avatars.discourse-cdn.com/v4/letter/d/f05b48/32.png) [@dasLuft](https://forum.kirupa.com/u/dasLuft)\
**Post date:** [September 17, 2013, 1:22pm UTC](https://forum.kirupa.com/t/trace-x2/331648/1 "2013-09-17T13:22:52Z")

</div>

So i got this function for using inventory items in a game i’m working on that looks like this:  
if (item is i){  
trace (item)  
for (r in receiver of quest item array){  
calculates distances  
if (player is near r and other conditions are met etc){  
trace(use the item)  
use the item, update the inventory  
}else{  
trace(drop the item)  
function to drop the item, update inventory  
}  
}  
}

The thing is this code is doing a double trace on the drop part if not near the receiver of the item.If in range i get one trace use and one drop.I have no idea why it is doing this. Any clues to why it runs the code twice?And how to fix this?  
I took out all the functions that might cause a bug and left just the trace and it just traces twice.If near “use/drop”, if out of range “drop/drop”

Thanks!
