Author Topic: Super Needs Help  (Read 3184 times)

It was the third post down from the topic you don't need to do a four hour bump Lol.

If you want to make it appear on a GUI you'll need a server and client add-on.
Client could have something like this:

function clientCmdsetBananas(%count) {
   if(%count > 0)
      GuiName.setText(%count);
}
So you can send the client the amount of bananas from the server and update the HUD.
okey dokey

Why is this not working
Code: [Select]
%this.Wallet = 1500;
if(%this.Wallet > 0)
clientCmdCenterPrint ("%this.Wallet, 2");
also how do you bottom print?
« Last Edit: April 27, 2015, 06:20:56 PM by SuperFlaminninja³ »

clientCmdBottomPrint

Why is this not working
Code: [Select]
%this.Wallet = 1500;
if(%this.Wallet > 0)
clientCmdCenterPrint ("%this.Wallet, 2");
also how do you bottom print?

Two reasons:
One, it doesn't appear to be in a function, so %this is undefined.
Two, you're using clientCmdCenterPrint wrong.

Code: [Select]
function serverCmdGiveMeMoney(%client) {
    %client.wallet = 1500;
    if(%client.wallet > 0) // will always be true.. unnecessary here
        %client.centerPrint(%this.wallet, 2);
}

Then your client can type /giveMeMoney into chat and it will put 1500 in their wallet and center print how much money they have for 2 seconds.

Two reasons:
One, it doesn't appear to be in a function, so %this is undefined.
Two, you're using clientCmdCenterPrint wrong.

Code: [Select]
function serverCmdGiveMeMoney(%client) {
    %client.wallet = 1500;
    if(%client.wallet > 0) // will always be true.. unnecessary here
        %client.centerPrint(%this.wallet, 2);
}

Then your client can type /giveMeMoney into chat and it will put 1500 in their wallet and center print how much money they have for 2 seconds.
What if I set it to a
Code: [Select]
function GameConnection::onClientEnterGame(%this.Wallet)And then set the display time to 0?

That function will work until something else uses the bottomprint, and you'd need to update it every time you changed the value or create a loop to do it. If you're going to be editing game functions make sure you understand how by reading this.

What if I set it to a
Code: [Select]
function GameConnection::onClientEnterGame(%this.Wallet)And then set the display time to 0?
The first variable in that function is always the client. You can't just replace it with his wallet, you'd still have to bottomprint in the onClientEnterGame function.

That function will work until something else uses the bottomprint, and you'd need to update it every time you changed the value or create a loop to do it. If you're going to be editing game functions make sure you understand how by reading this.
The first variable in that function is always the client. You can't just replace it with his wallet, you'd still have to bottomprint in the onClientEnterGame function.
So would I have it
Code: [Select]
(%client, % this.Wallet) or just client?

Just put client in that part. Those are only used when it is being called.

function gameConnection::onClientEnterGame(%this) {
   %this.bottomPrint(%this.wallet, -1);
   return parent::onClientEnterGame(%this);
}

Inside a package because you are editing a game function.
« Last Edit: April 27, 2015, 09:44:43 PM by Crøwn »

Just put client in that part. Those are only used when it is being called.

function gameConnection::onClientEnterGame(%this) {
   %this.bottomPrint(%this.wallet, -1);
   return parent::onClientEnterGame(%this);
}

Inside a package because you are editing a game function.
Thank you so much, I sat there all last night trying to figure out the syntax errors I wad getting

If I were to use a Continue Loop how would I use it to constantly update the bottom print and also would it create a lag?

If I were to use a Continue Loop how would I use it to constantly update the bottom print and also would it create a lag?
No, it won't create lag. You could either have a looping function that sends it to the whole server. Or one that loops per player.

You'd have to call this one once when the server starts.
Code: (Global) [Select]
function myFunction()
{
cancel($mySchedule);

commandToAll('bottomPrint', "My message", 3, 1);

$mySchedule = schedule(1, 0, myFunction);
}

You'd have to call this one once on every player when they first spawn.
Code: (Per Player) [Select]
function gameConnection::myLoop(%client)
{
cancel(%client.mySchedule);

commandToClient(%client, 'bottomPrint', "My message", 3, 1);

%client.schedule(1, myLoop);
}

No, it won't create lag. You could either have a looping function that sends it to the whole server. Or one that loops per player.

You'd have to call this one once when the server starts.
Code: (Global) [Select]
function myFunction()
{
cancel($mySchedule);

commandToAll('bottomPrint', "My message", 3, 1);

$mySchedule = schedule(1, 0, myFunction);
}

You'd have to call this one once on every player when they first spawn.
Code: (Per Player) [Select]
function gameConnection::myLoop(%client)
{
cancel(%client.mySchedule);

commandToClient(%client, 'bottomPrint', "My message", 3, 1);

%client.schedule(1, myLoop);
}
ok 2 questions if  I did have it start the loop for all would each player still have there own counter or would it be the hosts and also how do I check if client is host?

ok 2 questions if  I did have it start the loop for all would each player still have there own counter or would it be the hosts and also how do I check if client is host?
If you did the first one then everyone would have the same thing in their bottom print. Unless you did it like this:
Code: [Select]
function myFunction()
{
cancel($mySchedule);

%count = clientGroup.getCount();

for(%i = 0; %i < %count; %i++)
{
%client = clientGroup.getObject(%i);

commandToClient(%client, 'bottomPrint', "My message", 3, 1);
}

$mySchedule = schedule(1, 0, myFunction);
}

To check if someone is the host:
Code: [Select]
if(%client.isLocalConnection() || %client.BL_ID == getNumKeyID())
{
//Do stuff
}

No, it won't create lag. You could either have a looping function that sends it to the whole server. Or one that loops per player.

You'd have to call this one once when the server starts.

You'd have to call this one once on every player when they first spawn.

Be careful with the schedule interval, it's interpreted as milliseconds and 1 is much lower than necessary.
« Last Edit: April 28, 2015, 06:09:43 PM by Hime »

Be careful with the schedule interval, it's interpreted as milliseconds and 1 is much lower than necessary.
Yes I know.
« Last Edit: April 29, 2015, 08:27:01 AM by jes00 »