Author Topic: Gamemode code isn't working  (Read 1074 times)

Quote from: server.cs

fileCopy("Add-Ons/GameMode_LEGO/brickTOP.png", "base/data/shapes/brickTOP.png");
fileCopy("Add-Ons/GameMode_LEGO/brickBOTTOMLOOP.png", "base/data/shapes/brickBOTTOMLOOP.png");
fileCopy("Add-Ons/GameMode_LEGO/brickBOTTOMEDGE.png", "base/data/shapes/brickBOTTOMEDGE.png");
fileCopy("Add-Ons/GameMode_LEGO/brickSIDE.png", "base/data/shapes/brickSIDE.png");
fileCopy("Add-Ons/GameMode_LEGO/brickRAMP.png", "base/data/shapes/brickRAMP.png");

hammerImage.shapeFile = "./hammer.dts";
hammerItem.shapeFile = "./hammer.dts";

package GamemodePackage
{
   function GameConnection::CreatePlayer(%this, %spawn)
   {
      %return = Parent::CreatePlayer(%this, %spawn);
      
      if(isObject(%this.player))
      {
         %this.player.setDataBlock(MiniFig);
      }

   return %return;
}
activatePackage(GamemodePackage);

When I spawn with the game mode, none of these work.

Do you have GameMode_LEGO in the list of add-ons that your gamemode will run?

Do you have GameMode_LEGO in the list of add-ons that your gamemode will run?

Recently, yes.

But, I tested it but it didn't work.

You're calling the parent before it happens.
GameConnection::SpawnPlayer creates the player when you call the parent, which you are calling it when there's a chance that the player doesn't even exist. Returning this function is also recommended.

Do something like this:
Code: server.cs (19 lines)
package aaaa
{
    function GameConnection::SpawnPlayer(%this, %transform)
    {
        cancel(%this.applySchAAAA); //If a minigame resets, or whatever, usually ::SpawnPlayer is called multiple times, this will cancel it out and restart the schedule.
        %this.applySchAAAA = %this.schedule(250, ApplySomething);
        return Parent::SpawnPlayer(%this, %transform);
    }
};
activatePackage("aaaa");

function GameConnection::ApplySomething(%this)
{
    cancel(%this.applySchAAAA);
    if(!isObject(%player = %this.player))
        return;

    //Do stuff with %player
}

« Last Edit: November 25, 2015, 06:00:27 PM by Kyuande »

It is 100% okay to call stuff after the parent, that way you don't have to do silly scheduled stuff. He's even returning the value of the parent after all his packaged code so that's more right than what you did.

I'd just recommend using spawnplayer over createplayer.

The only working thing is the colorset.



It's supposed to have different brick textures and a different playertype...

Quote
do you have minifig enabled


It is 100% okay to call stuff after the parent, that way you don't have to do silly scheduled stuff. He's even returning the value of the parent after all his packaged code so that's more right than what you did.

I'd just recommend using spawnplayer over createplayer.
You're calling the parent before it happens.

There's a syntax error. The very last } needs a ; after it, because packages need those.

FileCooy doesn't work from zip files. So make sure your gamemode isn't a zip.

There's a syntax error. The very last } needs a ; after it, because packages need those.

Well, I guess this isn't that important after all. He didn't even bother to look in the console for error messages.

Maybe he just wants attention?

I don't think he pays attention to this topic anymore

FileCooy doesn't work from zip files. So make sure your gamemode isn't a zip.

Well, I guess this isn't that important after all. He didn't even bother to look in the console for error messages.

My GM is a folder.

Also what is FileCooy?

He meant FileCopy, lol

Can you read all the other posts on this topic?