On Fri, 3 Jan 1997, Nic Suzor wrote: > I am writing a special procedure to retrieve a players corpse when he dies. > now, i have set everything up so that corpse->owner_name returns the > players name, and i can compare one corpse with the pcs name. > > the problem i have is that when i have a room full of corpses, im not sure > how to search through all these corpses and pick out the first one which > owner_name matches with get_name(ch). i was thinking of a simple for loop, > but i am not sure how to make a new one. > > if someone can outline all the arguments in a for loop so i can make new > ones in future, it would be much appreciated :) First off, I'd suggest using their idnum instead of name. Comparing strings is slower than comparing integers. Secondly, the 'for' loop would be: struct obj_data *obj; for (obj = world[<room rnum>].contents; obj; obj = obj->next_content) if (GET_OBJ_TYPE(obj) == ITEM_CONTAINER && GET_OBJ_VAL(obj, 3)) if (obj->corpse_idnum == GET_IDNUM(ch)) break; It's not plugin code, of course. -- Daniel Koepke dkoepke@california.com Forgive me father, for I am sin. +-----------------------------------------------------------+ | Ensure that you have read the CircleMUD Mailing List FAQ: | | http://cspo.queensu.ca/~fletcher/Circle/list_faq.html | +-----------------------------------------------------------+
This archive was generated by hypermail 2b30 : 12/18/00 PST