Author Topic: How to Box a Player?  (Read 2199 times)

0 Members and 2 Guests are viewing this topic.

Offline squiddy

  • Soldat Beta Team
  • Camper
  • ******
  • Posts: 333
  • Flagger assassin
    • SoldatX
How to Box a Player?
« on: May 08, 2010, 04:37:49 pm »
I wanna know how the freak I do this:



If anyone can come up with a solution, I'll be thankfull.

I've already tried DrawText, but FloatToInt() doesn't work, obviously, and InterfaceImage() apparently doesn't work on 2.6.5.

Help! :(
www.soldatx.com.br - The brazilian Soldat community.

Offline Gizd

  • Flagrunner
  • ****
  • Posts: 586
  • (Re)tired
    • Eat-this! community site
Re: How to Box a Player?
« Reply #1 on: May 08, 2010, 04:42:01 pm »
You can't...

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: How to Box a Player?
« Reply #2 on: May 08, 2010, 05:23:14 pm »
Code: [Select]
function FloatToInt(flt: extended): integer;
begin
  Result := StrtoInt(FloattoStr(flt));
end;
I forget if Round exists, but in case that gives you complications:
Code: [Select]
function FloatToInt(flt: extended): integer;
begin
  Result := StrtoInt(FloattoStr(Round(flt)));
end;
although a floor function would be more appropriate.

Offline squiddy

  • Soldat Beta Team
  • Camper
  • ******
  • Posts: 333
  • Flagger assassin
    • SoldatX
Re: How to Box a Player?
« Reply #3 on: May 08, 2010, 06:41:44 pm »
Code: [Select]
function FloatToInt(flt: extended): integer;
begin
  Result := StrtoInt(FloattoStr(flt));
end;
I forget if Round exists, but in case that gives you complications:
Code: [Select]
function FloatToInt(flt: extended): integer;
begin
  Result := StrtoInt(FloattoStr(Round(flt)));
end;
although a floor function would be more appropriate.

Haha, I've already tried that.

It simply says:

"[Error] -> "18231319" is not an Integer Value".

:P

I tried that same thing :D
www.soldatx.com.br - The brazilian Soldat community.

Offline EnEsCe

  • Retired Soldat Developer
  • Flamebow Warrior
  • ******
  • Posts: 3101
  • http://enesce.com/
    • [eC] Official Website
Re: How to Box a Player?
« Reply #4 on: May 08, 2010, 07:48:22 pm »
Use StrToInt64 <-> Int64ToStr instead.
Or try the Int(FloatHere); function

Offline dnmr

  • Camper
  • ***
  • Posts: 315
  • emotionally handicapped
Re: How to Box a Player?
« Reply #5 on: May 09, 2010, 12:56:36 am »
wtf, you dont like round() ?

Offline tk

  • Soldier
  • **
  • Posts: 235
Re: How to Box a Player?
« Reply #6 on: May 09, 2010, 04:49:28 am »
or trunc()?


Quote
function FloatToInt(flt: extended): integer;
begin
  Result := StrtoInt(FloattoStr(flt));
end;

function FloatToInt(flt: extended): integer;
begin
  Result := StrtoInt(FloattoStr(Round(flt)));
end;
Why so? It's propably the most inefficient way available to convert a float to int.
« Last Edit: May 09, 2010, 04:52:43 am by tk »

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: How to Box a Player?
« Reply #7 on: May 09, 2010, 08:11:20 am »
It may be possible converting a float to a variant, and then to an integer, as another alternative.

I guess some people could do some speed tests to find the most efficient way one of these days.

Offline squiddy

  • Soldat Beta Team
  • Camper
  • ******
  • Posts: 333
  • Flagger assassin
    • SoldatX
Re: How to Box a Player?
« Reply #8 on: May 09, 2010, 09:20:19 am »
or trunc()?
[...]
Why so? It's propably the most inefficient way available to convert a float to int.

Integer is -65535 -> 65535. Some Singles are 3911391, far more big then an Integer.

Going to test Trunc(), anyways.

//~~~~~~

@DorkeyDear;

How? :O
www.soldatx.com.br - The brazilian Soldat community.

Offline tk

  • Soldier
  • **
  • Posts: 235
Re: How to Box a Player?
« Reply #9 on: May 09, 2010, 10:41:51 am »
Quote
Integer is -65535 -> 65535
Integer is -2147483648 -> 2147483647

Offline squiddy

  • Soldat Beta Team
  • Camper
  • ******
  • Posts: 333
  • Flagger assassin
    • SoldatX
Re: How to Box a Player?
« Reply #10 on: May 09, 2010, 11:24:45 am »
Quote
Integer is -65535 -> 65535
Integer is -2147483648 -> 2147483647

Right. Sorry :P

Word is 0 -> 65535 :P

Anyways, Trunc() messes up the position. It doesn't show the message on Player's X,Y. I'm going to do some more testing later, and then post the results here.
www.soldatx.com.br - The brazilian Soldat community.

Offline tk

  • Soldier
  • **
  • Posts: 235
Re: How to Box a Player?
« Reply #11 on: May 09, 2010, 11:53:48 am »
it doesn't mess up the postion, coords in DrawText are position on the screen, not on the map, which means it will never work with drawtext.

http://enesce.com/help/index.html?Functions/WorldText.html
You have to wait until 2.7.0 is out.
« Last Edit: May 09, 2010, 11:56:02 am by tk »

Offline squiddy

  • Soldat Beta Team
  • Camper
  • ******
  • Posts: 333
  • Flagger assassin
    • SoldatX
Re: How to Box a Player?
« Reply #12 on: May 09, 2010, 11:57:52 am »
it doesn't mess up the postion, coords in DrawText are position on the screen, not on the map, which means it will never work with drawtext.

http://enesce.com/help/index.html?Functions/WorldText.html
You have to wait until 2.7.0 is out.

I've tried with InterfaceImage() as well, but I use 2.6.5 :(
www.soldatx.com.br - The brazilian Soldat community.

Offline Gizd

  • Flagrunner
  • ****
  • Posts: 586
  • (Re)tired
    • Eat-this! community site
Re: How to Box a Player?
« Reply #13 on: May 09, 2010, 02:05:56 pm »
You'll still need to draw that box with ~50 Hz to make it smooth.

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: How to Box a Player?
« Reply #14 on: May 09, 2010, 02:24:21 pm »
@DorkeyDear;

How? :O
Untested:
Code: [Select]
function FloattoInt(Flt: extended): integer;
var
  vnt: variant;
begin
  vnt := Flt;
  Result := vnt;
end;
I really don't know if this will actually run or not, but looks like it should at least compile.
Of course you can change the type from extended to single or double or whatever.

Offline dnmr

  • Camper
  • ***
  • Posts: 315
  • emotionally handicapped
Re: How to Box a Player?
« Reply #15 on: May 09, 2010, 03:07:00 pm »
Curt.. do you seriously believe such an abomination would be more efficient than a built-in ROUND() function?

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: How to Box a Player?
« Reply #16 on: May 09, 2010, 08:58:44 pm »
Curt.. do you seriously believe such an abomination would be more efficient than a built-in ROUND() function?
Uhm, well, no. but I know some types (like TVarType) require being set as a variant to be converted to another type, and just thought it was at least worth mentioning as an alternative.

Offline Gizd

  • Flagrunner
  • ****
  • Posts: 586
  • (Re)tired
    • Eat-this! community site
Re: How to Box a Player?
« Reply #17 on: May 10, 2010, 12:43:28 pm »
Curt.. do you seriously believe such an abomination would be more efficient than a built-in ROUND() function?
Uhm, well, no. but I know some types (like TVarType) require being set as a variant to be converted to another type, and just thought it was at least worth mentioning as an alternative.
And only you use those types...