LucasRed

Textdraw/GUILabel com informações [VCMP:04rel004]

Oct 21st, 2017
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.52 KB | None | 0 0
  1. /*
  2.     Client
  3. */
  4. function Script::ScriptLoad()
  5. {
  6.     ::GUI_VEHICLE <-
  7.     {
  8.         ID = GUILabel( VectorScreen( 500, 500 ), Colour( 255, 255, 255 ) ),
  9.         HP = GUILabel( VectorScreen( 600, 500 ), Colour( 255, 255, 255 ) )
  10.     }
  11.  
  12.     ::GUI_VEHICLE[ "ID" ].FontName = "Verdana";
  13.     ::GUI_VEHICLE[ "ID" ].RemoveFlags( GUI_FLAG_VISIBLE );
  14.  
  15.     ::GUI_VEHICLE[ "HP" ].FontName = "Verdana";
  16.     ::GUI_VEHICLE[ "HP" ].RemoveFlags( GUI_FLAG_VISIBLE );
  17. }
  18. function Server::ServerData( stream )
  19. {
  20.     local intStream = stream.ReadInt();
  21.     if ( intStream == 1 )
  22.     {
  23.         ::GUI_VEHICLE[ "ID" ].AddFlags( GUI_FLAG_VISIBLE );
  24.         ::GUI_VEHICLE[ "HP" ].AddFlags( GUI_FLAG_VISIBLE );
  25.         local txt_split = split( stream.ReadString(), "\n" );
  26.         ::GUI_VEHICLE[ "ID" ].Text = txt_split[0];
  27.         ::GUI_VEHICLE[ "HP" ].Text = txt_split[1];
  28.     }
  29.     else if ( intStream == 2 )
  30.     {
  31.         ::GUI_VEHICLE[ "ID" ].RemoveFlags( GUI_FLAG_VISIBLE );
  32.         ::GUI_VEHICLE[ "HP" ].RemoveFlags( GUI_FLAG_VISIBLE );
  33.     }
  34. }
  35.  
  36. /*
  37.     Server
  38. */
  39. function onPlayerEnterVehicle( player, vehicle, door )
  40. {
  41.     pVehicle <- NewTimer( "getVehicleInfo", 1000, 0, player.ID );
  42. }
  43.  
  44. function onPlayerExitVehicle( player, vehicle )
  45. {
  46.     pVehicle.Delete();
  47.     local Stream = Stream();
  48.     Stream.StartWrite();
  49.     Stream.WriteInt( 2 );
  50.     Stream.SendStream( player );
  51. }
  52.  
  53. function getVehicleInfo( id )
  54. {
  55.     local player = FindPlayer( id );
  56.     if ( player )
  57.     {
  58.         local Stream = Stream();
  59.         Stream.StartWrite();
  60.         Stream.WriteInt( 1 );
  61.         Stream.WriteString( player.Vehicle.ID + "\n" + player.Vehicle.Health );
  62.         Stream.SendStream( player );
  63.     }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment