Ha ha ha! You know what caused this whole chat message thing??? Script_RPChat
I am now having trouble with chat messages. It seems that I can't send any chat message to the client, whether it is in a package or not. This is how I make chat messages:
%client.chatMessage("Looks like chat messages suddenly broke.");
If there is a problem with the code, please tell me.
The funny thing is that even when I type that in the console, like this:
function serverCmdcmt(%client){%client.chatMessage("Hello?");}
...it still doesn't work. Is this an error with v21 or what am I doing wrong?
Original post:
Yesterday, I made a script that had a GameConnection:: function inside it:
package spacerpserver
{
function GameConnection::onClientEnterGame(%client)
{
Parent::onClientEnterGame(%client);
%client.chatMessage("Welcome to \c3 Cowboy6's " @ $pref::server::name @ " ! \c6 This gamemode is custom-made by \c3 Hammereditor.");
bptoclient(%client);
%client.chatMessage("\c6 You can play with using commands such as /help, but download the client-sided script to have a cool GUI!");
%client.chatMessage("Sending chat messages requires \c4 Battery.\c0 It recovers over time, depending on your rank.");
}
};
activatePackage(spacerpserver);
...and it it didn't work. Other parts of my add-on didn't work, also, and when I removed the packages the functions were inside, everything kind of worked.
Somebody told me that you can't make functions with a Gameconnection:: parent outside of packages. Yet this package seems to be disabling the function. So I don't know what to do. If I remove the package, there will be a syntax error because game connections cant be outside packages. If I put it inside the pacakge, the function won't work. So what do I do?
Also, I'm having trouble with global variables. This doesn't work:
function t()
{
$t = getRandom(1, 5);
}
function s()
{
%r = $t;
}
I need to know how I can make a global variable inside a function, and use it inside another function. Does there have to be a package in between? Do they have to both be in a package? do they both have to be in the same package? Do they need to both be completely outside the package?