ItsMods

Full Version: Text not working and stuff?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
C++ Code
  1. #include common_scripts\utility;
  2. #include maps\mp\_utility;
  3. #include maps\mp\gametypes\_hud_util;
  4.  
  5. init()
  6. {
  7. level thread onPlayerConnect();
  8. }
  9.  
  10. onPlayerConnect()
  11. {
  12. while( true )
  13. {
  14. level waittill( "connected", player );
  15. player thread onPlayerSpawned();
  16. }
  17. }
  18.  
  19. onPlayerSpawned()
  20. {
  21. self endon( "disconnect" );
  22.  
  23. while( true )
  24. {
  25. self waittill( "spawned_player" );
  26. self thread spotEnemies();
  27. }
  28. }
  29.  
  30. spotEnemies()
  31. {
  32. self endon( "disconnect" );
  33. self endon( "death" );
  34.  
  35. distanceText = self createFontString( "smallfixed", 1 );
  36. distanceText setPoint( "CENTER", "CENTER", 10, 7 );
  37. distanceText.color = ( 51/255, 215/255, 54/255 );
  38. self thread destroyOnDeath( distanceText );
  39.  
  40. while( true )
  41. {
  42. wait .05;
  43.  
  44. //if( self getCurrentWeapon() != "binoculars_mp" )
  45. // continue;
  46.  
  47. if( !self playerADS() )
  48. continue;
  49.  
  50. start = self getTagOrigin( "tag_eye" );
  51. end = start + vector_scale( anglesToForward( self getPlayerAngles() ), 50000 );
  52. trace = bulletTrace( start, end, true, self );
  53.  
  54. meters = inchesToMetres( distance( start, trace["position"] ) );
  55. distanceText setText( meters + "m" );
  56.  
  57. if( !isDefined( trace["entity"] ) )
  58. continue;
  59.  
  60. if( !isPlayer( trace["entity"] ) )
  61. continue;
  62.  
  63. spottedEnemy = trace["entity"];
  64. spotFailed = false;
  65. for( i = 0; i < 30; i++ )
  66. {
  67. start = self getTagOrigin( "tag_eye" );
  68. end = start + vector_scale( anglesToForward( self getPlayerAngles() ), 50000 );
  69. trace = bulletTrace( start, end, true, self );
  70.  
  71. meters = inchesToMetres( distance( start, trace["position"] ) );
  72. distanceText setText( meters + "m" );
  73.  
  74. if( !isPlayer( trace["entity"] ) || ( trace["entity"] != spottedEnemy ) || !self playerADS() )
  75. {
  76. spotFailed = true;
  77. break;
  78. }
  79.  
  80. wait .05;
  81. }
  82.  
  83. if( spotFailed )
  84. continue;
  85.  
  86. self maps\mp\gametypes\_battlechatter_mp::mpSayLocalSound( self, "enemy", "infantry", false );
  87. self iPrintLnBold( "^2You spotted: " + trace["entity"].name );
  88. }
  89. }
  90.  
  91. destroyOnDeath( hudElem )
  92. {
  93. self waittill( "death" );
  94. hudElem destroy();
  95. }
  96.  
  97. inchesToMetres( inches )
  98. {
  99. return ( inches * 0.0254 );
  100. }


so .. it doesn't display a number at all and when I set developer to 1 it gives me a shitload of runtime errors which shouldn't cause problems.

whenever I look at a player for like 3 seconds it doesn't do anything either, and the player should shout "Enemy spotted!" and show which player u spotted.
not sure but:

change
Code:
distanceText.color = ( 51/255, 215/255, 54/255 );
to
Code:
distanceText.color = ( 0.2, 0.843, 0.211 );

did you ever check if the sound works at all before this?
make checks to see if pieces of code even get called (self iPrintLnBold())

not sure if this is the case now but with self getPlayerAngles() I have had problems before so I just used self.angles

and finally try changing
Code:
end = start + vector_scale( anglesToForward( self getPlayerAngles() ), 50000 );
to
Code:
end = start + anglestoforward(self.angles)*50000;
None of them worked .. =.=