I wonder if the invalid argument error occures cause of the following (quote from jcl from another topic about why ent_next gives an error when combined with ent_remove even when if (...pointer... != NULL) is done):

Quote:
No, it is not related just to the list, but can also happen in other circumstances. When you have two different actions running on the same entity, and the first action removes the entity at some point, the second action must test the used entity properties - name, position and so on - in order to detect if the entity is still there. Removed entities have no name, no flags, position is zero, and also all other entity properties are nonexistent or zero.
, global functions in a multiplayer games basically have 2 or more actions running the same entity (though they are the same), namely 1 for each server/client right? So perhaps Denn15 try checking if your pointers are valid by not only doing if (...pointer... != NULL) but also if(you->type != NULL). Just an idea, could be total rubbish.