Advertisement
PedroEduardo

[Include] pLoading v0.5

Sep 6th, 2017
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 3.82 KB | None | 0 0
  1. /*
  2. |====================================================|
  3. |++ Include     : pLoading.inc (v0.5)                |
  4. |++ Information : Load Screen (SinglePlayer)         |
  5. |++ Credits     : Toribio/Southclaw and PeterLinkson |
  6. |====================================================|
  7. */
  8.  
  9. #if defined _pLoading_included
  10.     #endinput
  11. #endif
  12.  
  13. #define _pLoading_included
  14.  
  15. #if !defined _progress2_included
  16.     #tryinclude <progress2>
  17.     #if !defined _progress2_included
  18.         #error could not locate progress2.inc file, download ( github.com/Southclaws/progress2 )
  19.     #endif
  20. #endif
  21.  
  22. enum pL_enum
  23. {
  24.     pL_Timer_TD,
  25.     pL_Timer_Bar,
  26.     pL_Timer_Fix,
  27.     Float:pL_Value,
  28.     Float:pL_Max,
  29.     PlayerBar:pL_Bar,
  30.     PlayerText:pL_TD
  31. };
  32.  
  33. new pL_Loading[MAX_PLAYERS][pL_enum];
  34.  
  35. public OnPlayerConnect(playerid)
  36. {
  37.     pL_Loading[playerid][pL_TD] = CreatePlayerTextDraw(playerid,0.0, 0.0, "_");
  38.     PlayerTextDrawFont(playerid, pL_Loading[playerid][pL_TD], 4);
  39.     PlayerTextDrawUseBox(playerid, pL_Loading[playerid][pL_TD], 1);
  40.     PlayerTextDrawTextSize(playerid, pL_Loading[playerid][pL_TD], 650.0, 470.0);
  41.    
  42.     pL_Loading[playerid][pL_Bar] = CreatePlayerProgressBar(playerid, 53.000000, 427.000000, 183.000000, 3.699997, -1429936641, 100.0, 0);
  43.    
  44.     #if defined pL_Load_OnPlayerConnect
  45.         pL_Load_OnPlayerConnect(playerid);
  46.     #endif
  47.     return 1;
  48. }
  49.  
  50. stock ShowPlayerLoading(playerid, Float:time)
  51. {
  52.     new pL_string[20], pL_number = random(14);
  53.    
  54.     pL_Loading[playerid][pL_Max] = time;
  55.  
  56.     if(pL_number == 0) pL_string = "loadsc1:loadsc1";
  57.     else format(pL_string, 20, "loadsc%d:loadsc%d", pL_number, pL_number);
  58.  
  59.     SetPlayerProgressBarMaxValue(playerid, pL_Loading[playerid][pL_Bar], pL_Loading[playerid][pL_Max]);
  60.     PlayerTextDrawSetString(playerid, pL_Loading[playerid][pL_TD], pL_string);
  61.  
  62.     pL_Loading[playerid][pL_Timer_Fix] = SetTimerEx("Loading_Fix", 2000, false, "d", playerid); //delay PlayAudioStream :/
  63.     PlayAudioStreamForPlayer(playerid, "https://dl.dropboxusercontent.com/s/hnlbexvsyobuc4o/Loading_Theme.mp3");
  64.     return 1;
  65. }
  66.  
  67. stock HidePlayerLoading(playerid)
  68. {
  69.     KillTimer(pL_Loading[playerid][pL_Timer_TD]);
  70.     KillTimer(pL_Loading[playerid][pL_Timer_Bar]);
  71.     KillTimer(pL_Loading[playerid][pL_Timer_Fix]);
  72.     TogglePlayerControllable(playerid, true);
  73.     StopAudioStreamForPlayer(playerid);
  74.     PlayerTextDrawHide(playerid, pL_Loading[playerid][pL_TD]);
  75.     HidePlayerProgressBar(playerid, pL_Loading[playerid][pL_Bar]);
  76.    
  77.     pL_Loading[playerid][pL_Value] = 0;
  78.     return 1;
  79. }
  80.  
  81. forward Loading_Fix(playerid);
  82. public Loading_Fix(playerid)
  83. {
  84.     TogglePlayerControllable(playerid, false);
  85.     PlayerTextDrawShow(playerid, pL_Loading[playerid][pL_TD]);
  86.     ShowPlayerProgressBar(playerid, pL_Loading[playerid][pL_Bar]);
  87.    
  88.     pL_Loading[playerid][pL_Timer_TD] = SetTimerEx("Loading_TD", 2750, true, "d", playerid);
  89.     pL_Loading[playerid][pL_Timer_Bar] = SetTimerEx("Loading_Bar", 50, true, "d", playerid);
  90.    
  91.     for(new i; i < 20; ++i) SendClientMessage(playerid, -1, "");
  92. }
  93.  
  94. forward Loading_TD(playerid);
  95. public Loading_TD(playerid)
  96. {
  97.     new pL_string[20], pL_number = random(14);
  98.  
  99.     if(pL_number == 0) pL_string = "loadsc1:loadsc1";
  100.     else format(pL_string, 20, "loadsc%d:loadsc%d", pL_number, pL_number);
  101.    
  102.     return PlayerTextDrawSetString(playerid, pL_Loading[playerid][pL_TD], pL_string);
  103. }
  104.  
  105. forward Loading_Bar(playerid);
  106. public Loading_Bar(playerid)
  107. {
  108.     if(pL_Loading[playerid][pL_Value] >= pL_Loading[playerid][pL_Max])
  109.     {
  110.         HidePlayerLoading(playerid);
  111.     }
  112.     else
  113.     {
  114.         pL_Loading[playerid][pL_Value] += 0.06;
  115.         SetPlayerProgressBarValue(playerid, pL_Loading[playerid][pL_Bar], pL_Loading[playerid][pL_Value]);
  116.     }
  117.     return 1;
  118. }
  119.  
  120.  
  121. #if defined _ALS_OnPlayerConnect
  122.     #undef OnPlayerConnect
  123. #else
  124.     #define _ALS_OnPlayerConnect
  125. #endif
  126. #define OnPlayerConnect pL_Load_OnPlayerConnect
  127. #if defined pL_Load_OnPlayerConnect
  128.     forward pL_Load_OnPlayerConnect(playerid);
  129. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement