Game Development Community

Spamming the client with a whole lotta nuthin

by Dreamer · in Torque Game Engine · 03/31/2005 (3:53 pm) · 14 replies

I've written some code to update the players speed at a keypress, for debugging purposes I want to see these happen in realtime, only problem is my code is spamming the client with a whole lotta 0's here is the code.
echo("Changed some client speedstuff");
MessageClient(%client,'SpeedChange','runforce  %1, maxForwardSpeed %2, maxBackwardSpeed %3, maxSideSpeed %4', %client.runForce, %client.MaxForwardSpeed,%client.maxBackwardSpeed,%client.maxSideSpeed);

Any ideas?

#1
03/31/2005 (4:19 pm)
MessageClient(%client,'SpeedChange','runforce  %1  maxForwardSpeed %2 maxBackwardSpe
ed %3 maxSideSpeed %4', %client.runForce, %client.MaxForwardSpeed,%client.maxBackwar
dSpeed,%client.maxSideSpeed);
#2
03/31/2005 (4:21 pm)
Yeah I know thats whats spamming the client, what I'm asking is why the whole thing is full of 0's when that SHOULD be reflecting the stats I just changed. :(
#3
03/31/2005 (5:05 pm)
I'm not sure if you looked very hard at that but your syntax was off.


What does your console say?


BTW, this belongs in the Public Mods section.
#4
03/31/2005 (7:49 pm)
My console says nothing relevant to this, I''ve looked and I'm not seeing where my syntax was off, so please help here, it's something simple and stupid I'm sure, but for now all I get is a bunch of 0's where the values should be.
#5
03/31/2005 (9:06 pm)
Let me shorten the variables so it's easier to follow, you can expand from there. You can't have those comma's inserted into your "tagged" string...

MessageClient(%cl,'SpeedChange','runforce  %1  mForSpd %2 mBackSpd %3 mSideSpd %4',
					%clrunForce, %cl.MaxForSpeed, %cl.maxBackSpeed, %cl.maxSideSpeed);
#6
04/01/2005 (6:32 am)
Ok I'm an idiot or something because I still don't see what you mean, the comma's are not in a tagged string near as I can tell.
#7
04/01/2005 (12:53 pm)
'runforce  %1, maxForwardSpeed %2, maxBackwardSpeed %3, maxSideSpeed %4'

I see commas in there.
#8
04/01/2005 (12:58 pm)
So do I.
#9
04/01/2005 (1:06 pm)
Ok those commas were intentional, but should I maybe have escaped them?
#10
04/01/2005 (6:22 pm)
Removing the commas did nothing :( Still the same problem, all values are 0 :(
#11
04/02/2005 (11:31 am)
The proper form would be:
MessageClient(%client,'SpeedChange','runforce  '@%1@'  maxForwardSpeed '@%2@'maxBackwardSpeed '@%3@' maxSideSpeed '@%4, %client.runForce, %client.MaxForwardSpeed,%client.maxBackwardSpeed,%client.maxSideSpeed);
or you could do:
%string $= ("runforce  "@%1@"  maxForwardSpeed "@%2@"maxBackwardSpeed "@%3@"maxSideSpeed "@%4);

MessageClient(%client,'SpeedChange', %string, %client.runForce, %client.MaxForwardSpeed,%client.maxBackwardSpeed,%client.maxSideSpeed);

The @'s will keep the strings on the same line, remove them and you will get a seperate line for each.

Each text string should be enclosed with 's while the actual variable should not.

I suggest you use an array instead of using %1 %2, etc Such as: %value[1] or %value.1
#12
04/02/2005 (4:01 pm)
Ahhh ok I see now, thank you very much... Is there somewhere that this is documented?
#13
04/02/2005 (11:35 pm)
Did that actually fix it?

Incidentally, have you tried manually echoing the values to be sure they're right?
#14
04/04/2005 (2:16 pm)
I have actually ceased work on the function itself, in favor of a cleaner solution posted in the resources section. I was trying to create a way to accelerate the player while the shift key was being pressed, but couldn't get it to function correctly, the above was just to let me know that my modified values were being applied properly.

In short, I was re-inventing the wheel, and it came out square :(

Incidently for those who are interested, here is what I was working on, maybe it can benefit someone.

In server/scripts/commands.cs
function ServerCmdPlayerSpeed(%client,%speedvar){
       if(%speedvar $="RUN"){
             %client.runForce *= 10;
             %client.maxForwardSpeed *= 10;
             %client.maxBackwardSpeed *= 10;
             %client.maxSideSpeed *= 10;
	     %client.horizMaxSpeed *=10;
	     %client.runForce *= 10;
	     echo(%client SPC "is running");
      }else{
            %client.runForce /= 10;
             %client.maxForwardSpeed /= 10;
             %client.maxBackwardSpeed /= 10;
             %client.maxSideSpeed /= 10;
	     %client.horizMaxSpeed *=10;
	     %client.runForce /= 10;
	     echo(%client SPC "is walking");
     }
      echo("Changed some client speedstuff");
      MessageClient(%client,'SpeedChange','runforce  %1 maxForwardSpeed %2 maxBackwardSpeed %3 maxSideSpeed %4', %client.runForce, %client.MaxForwardSpeed,%client.maxBackwardSpeed,%client.maxSideSpeed);
}
In client/scripts/defaultbinds.cs
function toggleRun(%val){
    if(%val){
        echo("Woohoo!, We\'re runnin!"); 
        CommandToServer('PlayerSpeed','RUN');
	$movementSpeed *= 10;
   }else{ 
         CommandToServer('PlayerSpeed','WALK');
         echo("Takin a Walk!");
	 $movementSpeed /= 10;
   }
}

moveMap.bind(keyboard,"lshift",toggleRun);

Hope someone can salvage somethin from that code, as I said it doesn't work and I'm not quite sure why (I know why the client message isn't working, I'm talking about the acceleration factor here)