Advertisement
PedroEduardo

[Include] pLoading v0.8

Sep 8th, 2017
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 4.67 KB | None | 0 0
  1. /*
  2. |====================================================|
  3. |++ Include     : pLoading.inc (v0.8)                |
  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. #if !defined pLoad_Sound
  23.     #define pLoad_Sound 2
  24. #endif
  25.  
  26. enum pL_enum
  27. {
  28.     pL_Timer_TD,
  29.     pL_Timer_Bar,
  30.     Float:pL_Value,
  31.     Float:pL_Max,
  32.     PlayerBar:pL_Bar,
  33.     PlayerText:pL_TD
  34. };
  35.  
  36. new pL_Loading[MAX_PLAYERS][pL_enum];
  37.  
  38. forward OnPlayerLoadingStart(playerid);
  39. forward OnPlayerLoadingEnd(playerid);
  40.  
  41. public OnPlayerConnect(playerid)
  42. {
  43.     pL_Loading[playerid][pL_TD] = CreatePlayerTextDraw(playerid,0.0, 0.0, "_");
  44.     PlayerTextDrawFont(playerid, pL_Loading[playerid][pL_TD], 4);
  45.     PlayerTextDrawUseBox(playerid, pL_Loading[playerid][pL_TD], 1);
  46.     PlayerTextDrawTextSize(playerid, pL_Loading[playerid][pL_TD], 650.0, 470.0);
  47.    
  48.     pL_Loading[playerid][pL_Bar] = CreatePlayerProgressBar(playerid, 53.000000, 427.000000, 183.000000, 3.699997, -1429936641, 100.0, 0);
  49.    
  50.     #if defined pL_Load_OnPlayerConnect
  51.         pL_Load_OnPlayerConnect(playerid);
  52.     #endif
  53.     return 1;
  54. }
  55.  
  56. stock ShowPlayerLoading(playerid, Float:time)
  57. {
  58.     CallLocalFunction("OnPlayerLoadingStart", "d", playerid);
  59.  
  60.     new pL_string[20], pL_number = random(14);
  61.    
  62.     pL_Loading[playerid][pL_Max] = time;
  63.  
  64.     if(pL_number == 0) pL_string = "loadsc1:loadsc1";
  65.     else format(pL_string, 20, "loadsc%d:loadsc%d", pL_number, pL_number);
  66.  
  67.     SetPlayerProgressBarMaxValue(playerid, pL_Loading[playerid][pL_Bar], pL_Loading[playerid][pL_Max]);
  68.     PlayerTextDrawSetString(playerid, pL_Loading[playerid][pL_TD], pL_string);
  69.  
  70.     TogglePlayerControllable(playerid, false);
  71.     PlayerTextDrawShow(playerid, pL_Loading[playerid][pL_TD]);
  72.     ShowPlayerProgressBar(playerid, pL_Loading[playerid][pL_Bar]);
  73.    
  74.     pL_Loading[playerid][pL_Timer_TD] = SetTimerEx("Loading_TD", 2750, true, "d", playerid);
  75.     pL_Loading[playerid][pL_Timer_Bar] = SetTimerEx("Loading_Bar", 50, true, "d", playerid);
  76.    
  77.     #if pLoad_Sound == 1
  78.         PlayAudioStreamForPlayer(playerid, "https://dl.dropboxusercontent.com/s/hnlbexvsyobuc4o/Loading_Theme.mp3");
  79.     #elseif pLoad_Sound == 2
  80.         PlayerPlaySound(playerid, 1062, 0.0, 0.0, 0.0);
  81.     #elseif pLoad_Sound == 3
  82.         PlayerPlaySound(playerid, 1068, 0.0, 0.0, 0.0);
  83.     #elseif pLoad_Sound == 4
  84.         PlayerPlaySound(playerid, 1076, 0.0, 0.0, 0.0);
  85.     #elseif pLoad_Sound == 5
  86.         PlayerPlaySound(playerid, 1097, 0.0, 0.0, 0.0);
  87.     #elseif pLoad_Sound == 6
  88.         PlayerPlaySound(playerid, 1183, 0.0, 0.0, 0.0);
  89.     #elseif pLoad_Sound == 7
  90.         PlayerPlaySound(playerid, 1185, 0.0, 0.0, 0.0);
  91.     #elseif pLoad_Sound == 8
  92.         PlayerPlaySound(playerid, 1187, 0.0, 0.0, 0.0);
  93.     #endif
  94.    
  95.     for(new i; i < 20; ++i) SendClientMessage(playerid, -1, "");
  96.     return 1;
  97. }
  98.  
  99. stock HidePlayerLoading(playerid)
  100. {
  101.     CallLocalFunction("OnPlayerLoadingEnd", "d", playerid);
  102.    
  103.     KillTimer(pL_Loading[playerid][pL_Timer_TD]);
  104.     KillTimer(pL_Loading[playerid][pL_Timer_Bar]);
  105.     TogglePlayerControllable(playerid, true);
  106.     PlayerTextDrawHide(playerid, pL_Loading[playerid][pL_TD]);
  107.     HidePlayerProgressBar(playerid, pL_Loading[playerid][pL_Bar]);
  108.    
  109.     pL_Loading[playerid][pL_Value] = 0;
  110.    
  111.     #if pLoad_Sound == 1
  112.         StopAudioStreamForPlayer(playerid);
  113.     #else
  114.         PlayerPlaySound(playerid, 1063, 0.0, 0.0, 0.0);
  115.     #endif
  116.     return 1;
  117. }
  118.  
  119. forward Loading_TD(playerid);
  120. public Loading_TD(playerid)
  121. {
  122.     new pL_string[20], pL_number = random(14);
  123.  
  124.     if(pL_number == 0) pL_string = "loadsc1:loadsc1";
  125.     else format(pL_string, 20, "loadsc%d:loadsc%d", pL_number, pL_number);
  126.    
  127.     return PlayerTextDrawSetString(playerid, pL_Loading[playerid][pL_TD], pL_string);
  128. }
  129.  
  130. forward Loading_Bar(playerid);
  131. public Loading_Bar(playerid)
  132. {
  133.     if(pL_Loading[playerid][pL_Value] >= pL_Loading[playerid][pL_Max])
  134.     {
  135.         HidePlayerLoading(playerid);
  136.     }
  137.     else
  138.     {
  139.         pL_Loading[playerid][pL_Value] += 0.06;
  140.         SetPlayerProgressBarValue(playerid, pL_Loading[playerid][pL_Bar], pL_Loading[playerid][pL_Value]);
  141.     }
  142.     return 1;
  143. }
  144.  
  145. #if defined _ALS_OnPlayerConnect
  146.     #undef OnPlayerConnect
  147. #else
  148.     #define _ALS_OnPlayerConnect
  149. #endif
  150. #define OnPlayerConnect pL_Load_OnPlayerConnect
  151. #if defined pL_Load_OnPlayerConnect
  152.     forward pL_Load_OnPlayerConnect(playerid);
  153. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement