Page 1 of 1

Freeze after spawning objects

Posted: 19 Jun 2014, 13:48
by racer_simon
Hey there,
I have a little problem with my gamemode script. I try to spawn objects on a map by using this code:

Code: Select all

// Load Objects
Void LoadObjects ()
{
    ItemList_Begin();
    ObjectsIds["Armor"] = ItemList_Add("SMCommon\\Pickups\\Armor.Item.gbx"); 
    ObjectsIds["Rocket"] = ItemList_Add("SMCommon\\Pickups\\Rocket.Item.gbx");
    ObjectsIds["Laser"] = ItemList_Add("SMCommon\\Pickups\\Laser.Item.gbx");
    ObjectsIds["Nucleus"] = ItemList_Add("SMCommon\\Pickups\\Nucleus.Item.gbx");
    ObjectsIds["Arrow"] = ItemList_Add("SMCommon\\Pickups\\Arrow.Item.gbx");
    ItemList_End();
}

Void SpawnObjects ()
{
    foreach (MapLandmark in MapLandmarks_ObjectAnchor)
    {
        declare CSmObject Object;
        switch (MapLandmark.Tag)
        {
            case "Armor": Object = ObjectCreate (ObjectsIds["Armor"]);
            case "Rocket": Object = ObjectCreate (ObjectsIds["Rocket"]);
            case "Laser": Object = ObjectCreate (ObjectsIds["Laser"]);
            case "Nucleus": Object = ObjectCreate (ObjectsIds["Nucleus"]);
            case "Arrow": Object = ObjectCreate (ObjectsIds["Arrow"]);
        }
        Object.SetAnchor (MapLandmark.ObjectAnchor);
    }
}
https://github.com/Ch4ll3ng3r/Maniascri ... Script.txt <-Complete Script
LoadObjects () is called, when the server starts, SpawnObjects () when a round begins.
Everything works fine. I can see the objects on the map, but from the start on my framerate drops until the game freezes and players do not spawn, although they should spawn.
It seems like the freeze comes from the objects, because without the objects the script runs fine.
But I do not really know how such code can cause a freeze.

Re: Freeze after spawning objects

Posted: 19 Jun 2014, 15:13
by steeffeen
how many object anchors are placed on the map?

Re: Freeze after spawning objects

Posted: 19 Jun 2014, 17:04
by racer_simon
I placed 5 anchors on the map.

Re: Freeze after spawning objects

Posted: 19 Jun 2014, 17:11
by steeffeen
racer_simon wrote:I placed 5 anchors on the map.
well that shouldn't be the problem then ^^
(the servers can only handle 255 objects)

Re: Freeze after spawning objects

Posted: 19 Jun 2014, 17:50
by racer_simon
https://www.youtube.com/watch?v=8JDZfrG2XO8
I hope this will help to understand my problem

Re: Freeze after spawning objects

Posted: 19 Jun 2014, 17:57
by steeffeen
just looked at the script after watching the video
you have a SpawnObjects (); call in the PlayLoop
the issue with that is that you keep spawning objects and reach the limit of 255 after less than one second

Re: Freeze after spawning objects

Posted: 19 Jun 2014, 18:36
by racer_simon
Oh damn, that was obvious^^