Author Topic: Won't let me spawn  (Read 2859 times)

I finally got my addon to display a gui without a cursor. However, It shows the gui, but doesn't spawn me in, I did parent the tweak. How can I spawn myself in?

Console
Code: [Select]
*** Phase 2: Download Ghost Objects
*** Phase 3: Mission Lighting
Mission lighting done

base/server/scripts/game.cs (534): Unable to find object: '' attempting to call function 'getBLID'
BackTrace: ->serverCmdMissionStartPhase3Ack->[HealthBar_Package]GameConnection::onClientEnterGame->[TC_Core_Main]GameConnection::onClientEnterGame->GameConnection::onClientEnterGame


base/server/scripts/game.cs (536): Unable to find object: '' attempting to call function 'schedule'
BackTrace: ->serverCmdMissionStartPhase3Ack->[HealthBar_Package]GameConnection::onClientEnterGame->[TC_Core_Main]GameConnection::onClientEnterGame->GameConnection::onClientEnterGame

In the code, I never even used getBLID. I did use the schedule for updating icons for another part of my addon and some other things, but I never overwrite the command itself. What am I doing wrong?
« Last Edit: March 24, 2015, 06:12:09 AM by Quinn Mallory »

Well. We can't know what you're doing wrong without seeing the code.

You probably passed the wrong argument to the parent statement (or no argument at all).

Well. We can't know what you're doing wrong without seeing the code.

Right. Sorry. Here:

client.cs
Code: [Select]
package HealthBar_Package
{
//A little UI Improvement
function UITweak(%client)
{
canvas.pushDialog(TC_HealthBar);
cursorOff();
}
function UIDisable::MainMenu()
{
canvas.popDialog(TC_HealthBar);
cursorOn();
}
function IconTweak(%icon)
{
canvas.pushDialog(%icon);
cursorOff();
}
function FastupdateIcon(%oldicon, %newicon)
{
canvas.popDialog(%oldicon);
IconTweak(%newicon);
}
//GameConnection
function GameConnection::OnClientEnterGame()
{
parent::onClientEnterGame();
UITweak();
}
function GameConnection::OnDisconnect()
{
parent::OnDisconnect();
UIDisable::MainMenu();
}

//Time Control Icons


function servercmdtimescale(%timescale)
{
if(%timescale = 2)
{
FastupdateIcon(TCIcon_Slow, TCIcon_FastForward);
}
if(%timescale = 0.2)
{
FastupdateIcon(TCIcon_FastForward, TCIcon_Slow);
}
if(%timescale = 1)
{
canvas.popDialog(TCIcon_FastForward);
canvas.popDialog(TCIcon_Slow);
}
}
};

server.cs
Code: [Select]
package TC_Core_Main
{
function GameConnection::onClientEnterGame(%this)
{
parent::onClientEnterGame(%this);
messageClient(%client, '', "<color:FFFFFF>This server is running TCcore <color:00ff00>"@ $TCcore::Version @ "<color:FFFFFF>.");
}
function setDelay(%delay, %a, %b)
{
if(%delay < 0)
{
echo("[Time Controls Core] says: ERROR! It can't be lower than 0. Will not issue...");
return %delay;
}
if(%delay > 30000)
{
echo("[Time Controls Core] says: ERROR! Delay too high! Will not issue...");
return %delay;
}
else
{
schedule(%delay, 0, %a, "");
schedule(%delay + 10, 0, %b, "");
}
}
function SFXDelay::TriggerPatch(%delay, %timecontrolAudioProfile)
{
if(%delay < 0)
{
echo("[Time Controls Core] says: ERROR! It can't be lower than 0. Will not issue...");
return %delay;
}
if(%delay > 2)
{
echo("[Time Controls Core] says: ERROR! Delay too high! Will not issue.");
return %delay;
}
if(%delay < 1)
{
echo("[Time Controls Core] says: Value is 1. The default is 0. Will not issue.");
return %delay;
}
else
{
schedule(%delay, 0, alxPlay(sfx_Trigger));
schedule(%delay + 2, alxPlay(%timecontrolAudioProfile));
}
}
function MountSFXProfile(%timescalevalue, %audioprofile)
{
if(servercmdtimescale(%timescalevalue))
{
SFXDelay::TriggerPatch(0,%audioprofile);
servercmdtimescale(%timescalevalue);
}
}
function servercmdtimescale(%timescale)
{
if(%timescale = 2)
{
MountSFXProfile(2, sfx_FastForward);
}
if(%timescale = 0.2)
{
MountSFXProfile(0.2, sfx_Slow);
}
if(%timescale = 1)
{
if(alxIsPlaying(sfx_Slow))
{
alxStop(sfx_Slow);
}
if(alxIsPlaying(sfx_FastForward))
{
alxStop(sfx_FastForward);
}
}
setTimescale(%timescale);
messageAll('', "<color:FFFFFF>[<color:00FF00>Time Controls Core<color:FFFFFF>] says: The timescale is now "@ %timescale @ ".");
}
function GameConnection::onDisconnect(%client)
{
parent::onDisconnect(%client);
deactivatePackage(HealthBar_Package);
}
};
« Last Edit: March 24, 2015, 09:38:29 PM by Quinn Mallory »

1. Your client-side/server-side seperation is all screwy. You're calling client-side functions from server-side methods inside client-side files. This will only work if the add-on is running on a listen server. Also note that those echos will echo to the server's console, not the clients
2. Your GameConnection:: methods need an argument for the client that is connecting, that then needs to be passed to the parent
« Last Edit: March 24, 2015, 09:52:30 PM by Headcrab Zombie »

Quote
   function GameConnection::onClientEnterGame(%this)
   {
      parent::onClientEnterGame(%this);
      messageClient(%client, '', "<color:FFFFFF>This server is running TCcore <color:00ff00>"@ $TCcore::Version @ "<color:FFFFFF>.");
   }

Don't do this. It's obnoxious.

Don't do this. It's obnoxious.
This too. It's annoying when you have several different add-ons spamming your chat when you join.
And quite frankly, no one cares.

1. Your client-side/server-side seperation is all screwy. You're calling client-side functions from server-side methods inside client-side files. This will only work if the add-on is running on a listen server. Also note that those echos will echo to the server's console, not the clients
2. Your GameConnection:: methods need an argument for the client that is connecting, that then needs to be passed to the parent

So, I should just release as client? But the health bar needs to be put in when the player spawns in-game. Suggestion?

So, I should just release as client? But the health bar needs to be put in when the player spawns in-game. Suggestion?
So put it in when the player spawns.
But do it using client-side functions
Type trace(1); in console, join a server, type trace(0);
Look through the console and look for any function relating to joining a server; package that.

Other things:

Don't put any functions between with serverCmd, other serverside functions and objects in a client.cs.
Don't put anything related to GUIs, functions beginning with clientCmd, or other clientside functions or objects in a server.cs
It may took a while to remember all of what's what, but here's a good way to do it:
When you're making add-ons, instead of a listen server (a server launched by click "Start Game" from the main  menu), instead launch a dedicated server, and then launch a client and join that server.
Then, when you're writing something in client.cs, only use functions or objects you can find and access in that.
Similar with server.cs, only use functions or objects you can find and access through the dedicated server console.

You're packaging and overriding serverCmdTimescale, but not calling the parent function. The timescale will never change.
There's some function (I'm assuming) you're creating, that don't exist outside the package. It's not a problem, but it's preferred to not place functions in a package if they don't need to be.
Don't name functions like function UIDisable::MainMenu() unless you have a reason to. It's typically reserved for methods, that is for example, creating a script object with class=UIDisable and then calling %scriptobject.MainMenu();....which doesn't really make sense semantically.

Also, when you're comparing two values, you have to use == instead of just one =. The single one is for setting variables, two of them is for comparison. And either you didn't show us the full files or you forgot to activate those packages.

Also, when you're comparing two values, you have to use == instead of just one =. The single one is for setting variables, two of them is for comparison.

Expanding on this, == is used to compare numerical values while $= is used to compare non-numeric or string values. $= can be used to compare all values because numbers will be converted to strings if needed, but == can not be used to compare strings.

e.g.
5 == 1 -> false
5 $= 1 -> false
5 $= 5 -> true
5 $= "five" -> false
"five" == "one" -> true
"five" $= "one" -> false
"five" $= "five" -> true