Author Topic: Position System  (Read 8850 times)

0 Members and 1 Guest are viewing this topic.

Offline Flockshot

  • Street Thug
  • *
  • Posts: 29
    • View Profile
Position System
« on: September 27, 2014, 10:12:48 pm »
Hello Guys I present u with m Positioning System.

So what basically it do is that it shows you ur position + angle + district name at will.

Using F3 Key you can enable/disable it.

Images




Global Variable
Code: [Select]
local posofplr = []; //Place it in any file but out of any function because we want it to be a global variable not local.

OnServerStart
Code: [Select]
xyz <- BindKey(true,0x72,0,0); //we will bind key for it to make it easy for player, F3.
showpos <- array( GetMaxPlayers(), false );
NewTimer("PlayerPos", 300, 0); //starts the timer

OnPlayerJoin
Code: [Select]
posofplr.push({Player = player, x = null, y = null, z = null, angle = null, district=null}); //We will push the player in the array we created.

OnKeyDown
Code: [Select]
function onKeyDown(player, bindid)
{
   if(bindid == xyz ) // xyz because we named the binding to this name
   {
      if(!showpos[player.ID]) //player will have it false when it enters the game
      {
         showpos[player.ID] = true; //Means player has the position system on
         MessagePlayer("Showing Coordinates",player);
      }
      else
      {
         showpos[player.ID]= false; //If the positioning system was on and the key was press again it will disable
         
      }
     
   }
}

Timer
Code: [Select]
function PlayerPos()
{
foreach (val in posofplr)
{
local plr = val.Player;

if(plr)
{

if(showpos[plr.ID])
{
if (val.x != null) val.x.Delete();
if (val.y != null) val.y.Delete();
if (val.z != null) val.z.Delete();
if (val.angle != null) val.angle.Delete();
if (val.district != null) val.district.Delete();

val.x = CreateTextdraw("X: " + val.Player.Pos.x, 0, 300, 0xFFB0B0B0);
val.y = CreateTextdraw("Y: " + val.Player.Pos.y, 0, 315, 0xFFB0B0B0);
val.z = CreateTextdraw("Z: " + val.Player.Pos.z, 0, 330, 0xFFB0B0B0);
val.angle = CreateTextdraw("Angle: " + val.Player.Angle, 0, 345, 0xFFB0B0B0);
val.district = CreateTextdraw("District: " + GetDistrictName( val.Player.Pos.x, val.Player.Pos.y ), 0, 360, 0xFFB0B0B0);

if (val.x != null) val.x.ShowForPlayer(val.Player);
if (val.y != null) val.y.ShowForPlayer(val.Player);
if (val.z != null) val.z.ShowForPlayer(val.Player);
if (val.angle != null) val.angle.ShowForPlayer(val.Player);
if (val.district != null) val.district.ShowForPlayer(val.Player);
}
}
else
{
if (val.x != null){ val.x.Delete();
val.x = null;}

if (val.y != null){ val.y.Delete();
val.y = null;}

if (val.z != null){ val.z.Delete();
val.z = null;}

if (val.angle != null){ val.angle.Delete();
val.angle = null;}

if (val.district != null){ val.district.Delete();
val.district = null;}
}
}
}

This is it for the Positioning system

Example Script: https://www.mediafire.com/?a6k18yne5m35ket

Special Thanks to : S.L.C for teaching me how to use the .push thingy.
« Last Edit: September 28, 2014, 06:14:38 pm by Flockshot »

Offline Mariu22S

  • Wiseguy
  • **
  • Posts: 78
  • VC-MP Maniac
    • View Profile
Re: Position System
« Reply #1 on: September 27, 2014, 10:33:52 pm »
Very nice :)

Offline sseebbyy

  • VC:MP Veteran
  • *****
  • Posts: 774
  • Immortal VC:MP Player
    • View Profile
    • Zombie Invasion => Server Forum [DEAD PROJECT]
Re: Position System
« Reply #2 on: September 27, 2014, 11:54:52 pm »
It looks good, but isn't it overlat on chat ? :/

Quote
Painful/Noob scripters acts like: I Am The Best Scripter Because I Announce My Releases With Big Font Size Without Giving Too Much Info' In The Hope They All Will Download And Check It. I Ignore Bad Replies, Replies That I Could Learn From, And Replies With So Much Text.



Offline [AoD]NC

  • VC:MP Beta Tester
  • VC:MP Veteran
  • *
  • Posts: 616
  • AoD forever!
    • View Profile
    • KURWA MAĆ
Re: Position System
« Reply #3 on: September 28, 2014, 02:00:12 am »
Mana :D.

Offline Flockshot

  • Street Thug
  • *
  • Posts: 29
    • View Profile
Re: Position System
« Reply #4 on: September 28, 2014, 08:07:23 am »
It looks good, but isn't it overlat on chat ? :/
Yeah i know so i changed it position to much lower

now its fine


Mana :D.
Thats just another thing.

Offline sseebbyy

  • VC:MP Veteran
  • *****
  • Posts: 774
  • Immortal VC:MP Player
    • View Profile
    • Zombie Invasion => Server Forum [DEAD PROJECT]
Re: Position System
« Reply #5 on: September 28, 2014, 11:06:38 am »
Much better.  :D

Quote
Painful/Noob scripters acts like: I Am The Best Scripter Because I Announce My Releases With Big Font Size Without Giving Too Much Info' In The Hope They All Will Download And Check It. I Ignore Bad Replies, Replies That I Could Learn From, And Replies With So Much Text.



Offline heekz.shadow

  • LU testers
  • Made Man
  • *
  • Posts: 249
    • View Profile
Re: Position System
« Reply #6 on: September 28, 2014, 12:49:35 pm »
I don't find it any clean that you're creating a new timer after a timer ends.

You should run an infinite timer, and please, not 100 miliseconds, that'll just lag a server with a decent playercount.
Code: [Select]
[20:23] <habi> later only i heard that lu chatbox is customizable. On my first visit, it appeared ugly.
[20:23] <habi> May be that also be the reason why lu has no players

Offline thijn

  • LU testers
  • VC:MP Veteran
  • *
  • Posts: 667
  • Im proud to be pro.
    • View Profile
    • Vice Underdogs
Re: Position System
« Reply #7 on: September 28, 2014, 01:04:27 pm »
Code: [Select]
if(showpos[player.ID]==false)
Should be
Code: [Select]
if(!showpos[player.ID])

Same with true, you don't need that there.
Also, there's no point in checking if it's true in an else if if the previous statement was false. It's either true or false.
Code: [Select]
if(!showpos[player.ID]) //player will have it false when it enters the game
{
}
else
{
}

And obviously what heekzs said, the timers are bad. Really bad.

Offline Flockshot

  • Street Thug
  • *
  • Posts: 29
    • View Profile
Re: Position System
« Reply #8 on: September 28, 2014, 03:14:28 pm »
I don't find it any clean that you're creating a new timer after a timer ends.

You should run an infinite timer, and please, not 100 miliseconds, that'll just lag a server with a decent playercount.

Code: [Select]
if(showpos[player.ID]==false)
Should be
Code: [Select]
if(!showpos[player.ID])

Same with true, you don't need that there.
Also, there's no point in checking if it's true in an else if if the previous statement was false. It's either true or false.
Code: [Select]
if(!showpos[player.ID]) //player will have it false when it enters the game
{
}
else
{
}

And obviously what heekzs said, the timers are bad. Really bad.

Updated the code.
Made the timer infinite and also changed the if and else .

Offline thijn

  • LU testers
  • VC:MP Veteran
  • *
  • Posts: 667
  • Im proud to be pro.
    • View Profile
    • Vice Underdogs
Re: Position System
« Reply #9 on: September 28, 2014, 05:04:56 pm »
Ouch, that will spawn an infinite timer every time a player presses F3 two times.
It's better if you use one, infinite timer that will loop through all the players and update the text if they have the system enabled. That way you'll only end up with one timer overall, instead of a million after your server has run for an hour or two.

Offline Flockshot

  • Street Thug
  • *
  • Posts: 29
    • View Profile
Re: Position System
« Reply #10 on: September 28, 2014, 06:16:07 pm »
Ouch, that will spawn an infinite timer every time a player presses F3 two times.
It's better if you use one, infinite timer that will loop through all the players and update the text if they have the system enabled. That way you'll only end up with one timer overall, instead of a million after your server has run for an hour or two.
In that case i will just make a infinite timer on server start.
Well updated the code