pos saving on notepad

MEGAMIND

  • Hero Member
  • Developer of Webnet Official
  • Posts: 807
pos saving on notepad
« on June 25th, 2017, 03:36 PM »
hi and how's everyone its a good day and hope u all are fine too Eid mubarak to all

hi i was searching for a code i founded in my old 2year book there was a code like fopen which lets you save anything on a notepad hows that possible in vcmp any ideas


i need to save player.pos on my notepad any ideas thnx for helping.........

vito1

  • Guest
Re: pos saving on notepad
« Reply #1, on June 25th, 2017, 03:43 PM »
Code: [Select]
function onPlayerCommand( player, cmd, text ){
if(cmd == "pos"){
MessagePlayer( player.Pos.x +","+ player.Pos.y +","+ player.Pos.z +","+ player.Angle, player);
}
}
log located in %AppData%\VCMP\04beta\serverlogs\<your server>

.

  • VC:MP Beta Tester
  • .
  • Posts: 1,808
.

MEGAMIND

  • Hero Member
  • Developer of Webnet Official
  • Posts: 807
Re: pos saving on notepad
« Reply #3, on June 25th, 2017, 04:22 PM »
Quote from vito1 on June 25th, 2017, 03:43 PM
Code: [Select]
function onPlayerCommand( player, cmd, text ){
if(cmd == "pos"){
MessagePlayer( player.Pos.x +","+ player.Pos.y +","+ player.Pos.z +","+ player.Angle, player);
}
}
log located in %AppData%\VCMP\04beta\serverlogs\<your server>
your code didnt worked its like this
 
function onPlayerCommand( player, cmd, text )
{
 if(cmd == "pos")
{
 MessagePlayer( ""+player.Pos.x +","+ player.Pos.y +","+ player.Pos.z +","+ player.Angle, player);
 }
}

btw thanks

.

  • VC:MP Beta Tester
  • .
  • Posts: 1,808
Re: pos saving on notepad
« Reply #4, on June 25th, 2017, 06:08 PM »
Why do you retrieve a position instance every time to print each member individually? Wouldn't it just be easier to do:

Code: [Select]
print/Message/whatever(player.Pos + " " + player.Angle);

Things do know to convert themselves to strings. You don't have to do it yourself in the least efficient way.
.

vito1

  • Guest
Re: pos saving on notepad
« Reply #5, on June 25th, 2017, 06:30 PM »
Quote from . on June 25th, 2017, 06:08 PM
Why do you retrieve a position instance every time to print each member individually? Wouldn't it just be easier to do:
Things do know to convert themselves to strings.
1) It's important for performance, but not development commands.
2) To keep my-own format of output, without those ( ), I prefer to call instance few times in row than manually copy-pasting text. Of course it depends of one's needs.

.

  • VC:MP Beta Tester
  • .
  • Posts: 1,808
Re: pos saving on notepad
« Reply #6, on June 25th, 2017, 06:37 PM »Last edited on June 25th, 2017, 06:46 PM
Quote from vito1 on June 25th, 2017, 06:30 PM
1) It's important for performance, but not development commands.
Efficiency is not strictly limited to performance. There can also be efficiency in how clean your code looks and how fast you write it.
Quote from vito1 on June 25th, 2017, 06:30 PM
2) To keep my-own format of output, without those ( ), ...
If anything, those () make it easier to understand what the value is/was. If you print four floats in a row you can mistake them for a quaternion. And it's not as if you're parsing things back and trying to conserve space (as if choosing a text format is an indication that you need to conserve space).
Quote from vito1 on June 25th, 2017, 06:30 PM
... I prefer to call instance few times in row than manually copy-pasting text. ...
I'm sorry, what?



Please put a little more effort in finding a better argument. Not that there needs to be one.
.

vito1

  • Guest
Re: pos saving on notepad
« Reply #7, on June 25th, 2017, 06:47 PM »Last edited on June 25th, 2017, 06:52 PM by vito1
Quote from . on June 25th, 2017, 06:37 PM
If you print four floats in a row you can mistake them for a quaternion
Nope, since I know what I expect in output.
I prefer to use position-angle format as one array [x,y,z,angle] to manage player's position. So it's easy to copy-paste this format (for me). And faster to code ;)

Mötley

  • Hero Member
  • Posts: 775
Re: pos saving on notepad
« Reply #8, on June 27th, 2017, 01:35 AM »
You posted a bad post in LU about saving positions, So I created a fast snippet to clear the future confusion.

All you had was

Code: [Select]
else if( szCommand == "s" )
{
 print( pPlayer.Pos );
 }



You deleted the post and took ownership of my fastly thrown together crappy code. I know how you like to lock topics so I had to code that in literally one minute :/

http://forum.liberty-unleashed.co.uk/index.php?topic=2925.msg15121;topicseen#new

Code: [Select]
Player_Pos <- array(GetMaxPlayers());

class Player_Stores_Pos
{
  /* No true reason to set these as floats */
 
  X = 0;
  Y = 0;
  Z = 0;

  Position_Exist = false;
 
}

function onPlayerCommand(player, cmd, text)
{
  if ( cmd == "print")
  {
    if (player.Spawned)
    {
     
      local pos = player.Pos, x = pos.x, y = pos.y, z = pos.z;

      /* This print will return a vector that can be copied and pasted via in scripting */
      print("Vector( " + x + ", " + y + ", " + z +");" );

      return true
    }
    else MessagePlayer("You never spawned", player, 255, 0, 0);
  }

  //--------------------------------------------------------------------------

  if ( cmd == "setclass")
  {
     /* You should add this on player join instead */
     Player_Pos[player.ID] = Player_Stores_Pos();

     MessagePlayer("You have set the position class", player, 100, 0, 115);

     return true;
  }

  if ( cmd == "endclass")
  {
     /* You should add this on player part instead */
     Player_Pos[player.ID] = null;

     MessagePlayer("You have cleared the position array", player, 100, 0, 115);

     return true;
  }

  //--------------------------------------------------------------------------

  if ( cmd == "save")
  {
    if (player.Spawned)
    {
     
      local pos = player.Pos, x = pos.x, y = pos.y, z = pos.z;
     
      /* Now store the positions */
      Player_Pos[player.ID].X = x;
      Player_Pos[player.ID].Y = y;
      Player_Pos[player.ID].Z = z;

      Player_Pos[player.ID].Position_Exist = true;

      local District = GetDistrictName(Player_Pos[player.ID].X, Player_Pos[player.ID].Y);
      MessagePlayer("Position Saved in: " + District, player, 100, 0, 115);

      return true
    }
    else MessagePlayer("You never spawned", player, 255, 0, 0);
  }

  if ( cmd == "load")
  {
    if (player.Spawned)
    {
      if (Position_Exist == true)
      {
        player.Pos = Vector(Player_Pos[player.ID].X, Player_Pos[player.ID].Y, Player_Pos[player.ID].Z);
      }
      else MessagePlayer("I think you forgot to save a position ? :P xD", player, 255, 255, 33);

      return true
    }
    else MessagePlayer("You never spawned", player, 255, 0, 0);
  }

  //--------------------------------------------------------------------------
 
  return 1;
}

You obviously haven't learned anything.... ;D ;D ;D ;D

MEGAMIND

  • Hero Member
  • Developer of Webnet Official
  • Posts: 807
Re: pos saving on notepad
« Reply #9, on June 27th, 2017, 07:36 PM »
Quote from TurboGrafx on June 27th, 2017, 01:35 AM
You posted a bad post in LU about saving positions, So I created a fast snippet to clear the future confusion.

All you had was

Code: [Select]
else if( szCommand == "s" )
{
 print( pPlayer.Pos );
 }



You deleted the post and took ownership of my fastly thrown together crappy code. I know how you like to lock topics so I had to code that in literally one minute :/

http://forum.liberty-unleashed.co.uk/index.php?topic=2925.msg15121;topicseen#new

Code: [Select]
Player_Pos <- array(GetMaxPlayers());

class Player_Stores_Pos
{
  /* No true reason to set these as floats */
 
  X = 0;
  Y = 0;
  Z = 0;

  Position_Exist = false;
 
}

function onPlayerCommand(player, cmd, text)
{
  if ( cmd == "print")
  {
    if (player.Spawned)
    {
     
      local pos = player.Pos, x = pos.x, y = pos.y, z = pos.z;

      /* This print will return a vector that can be copied and pasted via in scripting */
      print("Vector( " + x + ", " + y + ", " + z +");" );

      return true
    }
    else MessagePlayer("You never spawned", player, 255, 0, 0);
  }

  //--------------------------------------------------------------------------

  if ( cmd == "setclass")
  {
     /* You should add this on player join instead */
     Player_Pos[player.ID] = Player_Stores_Pos();

     MessagePlayer("You have set the position class", player, 100, 0, 115);

     return true;
  }

  if ( cmd == "endclass")
  {
     /* You should add this on player part instead */
     Player_Pos[player.ID] = null;

     MessagePlayer("You have cleared the position array", player, 100, 0, 115);

     return true;
  }

  //--------------------------------------------------------------------------

  if ( cmd == "save")
  {
    if (player.Spawned)
    {
     
      local pos = player.Pos, x = pos.x, y = pos.y, z = pos.z;
     
      /* Now store the positions */
      Player_Pos[player.ID].X = x;
      Player_Pos[player.ID].Y = y;
      Player_Pos[player.ID].Z = z;

      Player_Pos[player.ID].Position_Exist = true;

      local District = GetDistrictName(Player_Pos[player.ID].X, Player_Pos[player.ID].Y);
      MessagePlayer("Position Saved in: " + District, player, 100, 0, 115);

      return true
    }
    else MessagePlayer("You never spawned", player, 255, 0, 0);
  }

  if ( cmd == "load")
  {
    if (player.Spawned)
    {
      if (Position_Exist == true)
      {
        player.Pos = Vector(Player_Pos[player.ID].X, Player_Pos[player.ID].Y, Player_Pos[player.ID].Z);
      }
      else MessagePlayer("I think you forgot to save a position ? :P xD", player, 255, 255, 33);

      return true
    }
    else MessagePlayer("You never spawned", player, 255, 0, 0);
  }

  //--------------------------------------------------------------------------
 
  return 1;
}

You obviously haven't learned anything.... ;D ;D ;D ;D
I think u still didnt got my question do u well the problem was solved my self in Lu and vcmp both the code u replied to my question is irrelevant thnx for being over efficient problem solved locking topic