Author Topic: moving a player like a brick  (Read 3780 times)

Type the / command into chat, not consol



Now it works but it crashes when I:
A: type the command again
B: the person being controlled dies
C: I plant the person

Help plz

The only problem with setting the player to a temp brick is that you need to add all this other stuff related to cancelling the normal brick placement system while the player is selected.  I will post my *God Control* when I get home. Note: I didn't ever take the time to fix the brick placement while god controlling.

Also, from my experience, these things can happen when using brick functions other than the movement:
-Crash of game (If pressing [1]-[0], , and I think something else.)
-Deletion of player (Pressing
  • on numpad, can be fixed by spawnPlayer(blahblahblah) or joining/making a minigame [or if he is in the minigame, resetting it])


I think SolarFlare took the time to fix the problems but you are better of fixing by yourself by "blanking" out the commands related to brick placement for the duration you are controlling a player.
« Last Edit: February 12, 2008, 10:11:19 PM by Trigun »

Well, I just tested.  It works.

1. Put my code in a notepad file and save.
2. Name the file "Script_ControlPlayer.cs" and put it in the "[Blockland]\Add-Ons" folder.
3. Enable the Add-On in the Add-Ons menu of the Start Server GUI.
4. Start a server.
5. Get a brick from the brick menu and place (not plant) a ghost brick.
6. Open the chat HUD, type "\controlPlayer YourNameHere" and press "Enter".
7. Control yourself using your normal brick shifting / rotating keys.
8. Profit.

Until you package out the fxDTSBrick::Plant() method and the brick weapon's Fire() method, it'll crash if you do certain things.

You'll also want to disable the player from controlling himself.

@ Trigun:

This is probably the easiest way of doing it.  Sure, it's more work on the coder's end, but much, much less work on the user's end.  Typically, that's what you want to strive for less work for the user.

ohai trader, that works too XD but wut about pressing and [1]-[0]


Code: [Select]
function ServerCmdGodControl(%client,%name)
{
if(%client.isSuperAdmin || %client.isAdmin)
{
%targetClient = FindClientByName(%name);
%client.player.tempBrick = %targetClient.player;
centerPrintAll("\c2" @ %client.name SPC "\c6Is God Controlling \c3" @ %targetClient.name,5,1);
}
}
This is my *God Control* function.  It may not be the most preffered way but it works.

Another suggestion, you may want to remove the player's previous temp brick if it isn't a player.

To "blank" out things, just do something like this:
Code: [Select]
function Lolwut(%client,%lolwut)
{
     if(%client.isControllingAPlayer)
     {
     }
     else
     {
          parent::Lolwut(%client,%lolwut);
     }
}

Then you might want to add "%client.isControllingAPlayer = True;" or something in your function.

Your code does nothing that mine doesn't do.  Trigun just wants to be heard, lol.  I will however modify my code to make sure players as tempBricks aren't deleted.  Anyway, your code doesn't even check whether the target client has a player object.  Lame.

Code: [Select]
function serverCmdControlPlayer(%client,%name)
{
if(%client.isAdmin || %client.isSuperAdmin)
{
%victim = findClientByName(%name);

if(isObject(%victim) && isObject(%victim.Player) && isObject(%client.Player))
{
if(isObject(%client.Player.tempBrick) && %client.Player.tempBrick.getClassName() !$= "Player")
{
%client.Player.tempBrick.delete();
}

%client.Player.tempBrick = %victim.Player;
}
}
}

To "blank" out things, just do something like this:
Code: [Select]
function Lolwut(%client,%lolwut)
{
     if(%client.isControllingAPlayer)
     {
     }
     else
     {
          parent::Lolwut(%client,%lolwut);
     }
}

Then you might want to add "%client.isControllingAPlayer = True;" or something in your function.

No.

Code: [Select]
function Lolwut(%client,%lolwut)
{
     if(!%client.isControllingAPlayer)
     {
          parent::Lolwut(%client,%lolwut);
     }
}

To "blank" out things, just do something like this:
Code: [Select]
function Lolwut(%client,%lolwut)
{
     if(%client.isControllingAPlayer)
     {
     }
     else
     {
          parent::Lolwut(%client,%lolwut);
     }
}

Then you might want to add "%client.isControllingAPlayer = True;" or something in your function.

No.

Code: [Select]
function Lolwut(%client,%lolwut)
{
     if(!%client.isControllingAPlayer)
     {
          parent::Lolwut(%client,%lolwut);
     }
}

No.

Code: [Select]
function Lolwut(%client,%lolwut)
{
     if(!%client.isControllingAPlayer)
          parent::Lolwut(%client,%lolwut);
}

That'll sting in the morning.

To "blank" out things, just do something like this:
Code: [Select]
function Lolwut(%client,%lolwut)
{
     if(%client.isControllingAPlayer)
     {
     }
     else
     {
          parent::Lolwut(%client,%lolwut);
     }
}

Then you might want to add "%client.isControllingAPlayer = True;" or something in your function.

No.

Code: [Select]
function Lolwut(%client,%lolwut)
{
     if(!%client.isControllingAPlayer)
     {
          parent::Lolwut(%client,%lolwut);
     }
}

No.

Code: [Select]
function Lolwut(%client,%lolwut)
{
     if(!%client.isControllingAPlayer)
          parent::Lolwut(%client,%lolwut);
}

Same thing.