Thanks for all the help so far,
I tried the code and as Kartoffel said, the problem is somewhere else.
I did not include the following because I thought it would not be important.
This Entity that I want to create every loop, shall after it is created do a c_scan to scan for other entities.
Like the following:
while (1)
{
ENTITY* dummy;
dummy = ent_create (NULL, vector(1,1,1), NULL);
dummy.emask = ENABLE_DETECT;
dummy.event = message_on_screen;
c_scan(dummy.x,dummy.pan,vector(360,180,1000),SCAN_ENTS | IGNORE_ME);
wait(1);
ptr_remove(dummy);
wait(-1);
}
When I remove the c_scan, all of the rest works fine.
With the c_scan enabled, the loop will trigger my event one time and crash the next time.
Edit: There are other Entities around so the event gets triggered, they have nothing to do with this script.