Freeze after spawning objects

Discuss everything related to custom data creation.

Moderator: NADEO

Post Reply
User avatar
racer_simon
Posts: 52
Joined: 02 Jul 2011, 11:40

Freeze after spawning objects

Post 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.
User avatar
steeffeen
Translator
Translator
Posts: 2463
Joined: 14 Oct 2012, 16:22
Location: Germany

Re: Freeze after spawning objects

Post by steeffeen »

how many object anchors are placed on the map?
    Game Mode and Title Pack Creator, Developer, ShootMania-Player & more

    ManiaControl, FancyManiaLinks
    User avatar
    racer_simon
    Posts: 52
    Joined: 02 Jul 2011, 11:40

    Re: Freeze after spawning objects

    Post by racer_simon »

    I placed 5 anchors on the map.
    User avatar
    steeffeen
    Translator
    Translator
    Posts: 2463
    Joined: 14 Oct 2012, 16:22
    Location: Germany

    Re: Freeze after spawning objects

    Post 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)
      Game Mode and Title Pack Creator, Developer, ShootMania-Player & more

      ManiaControl, FancyManiaLinks
      User avatar
      racer_simon
      Posts: 52
      Joined: 02 Jul 2011, 11:40

      Re: Freeze after spawning objects

      Post by racer_simon »

      https://www.youtube.com/watch?v=8JDZfrG2XO8
      I hope this will help to understand my problem
      User avatar
      steeffeen
      Translator
      Translator
      Posts: 2463
      Joined: 14 Oct 2012, 16:22
      Location: Germany

      Re: Freeze after spawning objects

      Post 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
        Game Mode and Title Pack Creator, Developer, ShootMania-Player & more

        ManiaControl, FancyManiaLinks
        User avatar
        racer_simon
        Posts: 52
        Joined: 02 Jul 2011, 11:40

        Re: Freeze after spawning objects

        Post by racer_simon »

        Oh damn, that was obvious^^
        Post Reply

        Return to “Title Pack & Custom Data Creation”

        Who is online

        Users browsing this forum: No registered users and 1 guest