Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as Plain Text by Hoss ( 13 years ago )
// Specially for COD5 Gang Wars server

#include <a_samp>
#include <zcmd>
#include <sscanf2>

#define TURF_TEST    (1)

#define INITITAL_BAR_SIZE   (442.000000)
#define FINAL_BAR_SIZE   (613.000000)

new
Loading_Progress[MAX_PLAYERS],
Loading_EndCount[MAX_PLAYERS],
Loading_Timer[MAX_PLAYERS],
Loading_Event[MAX_PLAYERS],
Loading_TempStr[32]
;

new
Text:ProgressBG = Text:INVALID_TEXT_DRAW,
PlayerText:ProgressTex[MAX_PLAYERS] = { PlayerText:INVALID_TEXT_DRAW, ... },
PlayerText:ProgressBar[MAX_PLAYERS] = { PlayerText:INVALID_TEXT_DRAW, ... },
PlayerText:ProgressSec[MAX_PLAYERS] = { PlayerText:INVALID_TEXT_DRAW, ... },
PlayerText:ProgressPer[MAX_PLAYERS] = { PlayerText:INVALID_TEXT_DRAW, ... }
;

public OnGameModeInit()
{
 // Don't use these lines if it's a filterscript
 SetGameModeText("Blank Script");
 AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);

 ProgressBG =
 TextDrawCreate(620.000000, 314.000000, "   ");
 TextDrawBackgroundColor(ProgressBG, 255);
 TextDrawFont(ProgressBG, 1);
 TextDrawLetterSize(ProgressBG, 0.500000, 1.000000);
 TextDrawColor(ProgressBG, -1);
 TextDrawSetOutline(ProgressBG, 0);
 TextDrawSetProportional(ProgressBG, 1);
 TextDrawSetShadow(ProgressBG, 1);
 TextDrawUseBox(ProgressBG, 1);
 TextDrawBoxColor(ProgressBG, 255);
 TextDrawTextSize(ProgressBG, 435.000000, 0.000000);
 return 1;
}
CMD:loadingtest(playerid,params[])
{
 new time;
 if(!sscanf(params, "i", time))
 {
  //                   TURF NAME | Sec | Text
  StartProgressBar(playerid, TURF_TEST, time, "~r~TAKING TURF: ~g~Please wait...");
 }
 return 1;
}
CMD:stopload(playerid,params[])
{
 StopProgressBar(playerid);
 return 1;
}
stock StartProgressBar(playerid, eventid, seconds, text[])
{
 if(seconds <= 0 || Loading_EndCount[playerid]) StopProgressBar(playerid);

 TextDrawShowForPlayer(playerid, ProgressBG);

 ProgressTex[playerid] =
 CreatePlayerTextDraw(playerid, 437.000000, 298.000000, (text[0] != '\0') ? text : ("In Progress, Please wait.."));
 PlayerTextDrawBackgroundColor(playerid, ProgressTex[playerid], 255);
 PlayerTextDrawFont(playerid, ProgressTex[playerid], 1);
 PlayerTextDrawLetterSize(playerid, ProgressTex[playerid], 0.390000, 1.400000);
 PlayerTextDrawColor(playerid, ProgressTex[playerid], -1);
 PlayerTextDrawSetOutline(playerid, ProgressTex[playerid], 1);
 PlayerTextDrawSetProportional(playerid, ProgressTex[playerid], 1);
 PlayerTextDrawShow(playerid, ProgressTex[playerid]);

 ProgressBar[playerid] =
 CreatePlayerTextDraw(playerid, 442.000000, 316.000000, "_");
 PlayerTextDrawBackgroundColor(playerid, ProgressBar[playerid], 255);
 PlayerTextDrawFont(playerid, ProgressBar[playerid], 1);
 PlayerTextDrawLetterSize(playerid, ProgressBar[playerid], 0.500000, 1.500000);
 PlayerTextDrawColor(playerid, ProgressBar[playerid], -1);
 PlayerTextDrawSetOutline(playerid, ProgressBar[playerid], 0);
 PlayerTextDrawSetProportional(playerid, ProgressBar[playerid], 1);
 PlayerTextDrawSetShadow(playerid, ProgressBar[playerid], 1);
 PlayerTextDrawUseBox(playerid, ProgressBar[playerid], 1);
 PlayerTextDrawBoxColor(playerid, ProgressBar[playerid], 9895935);
 PlayerTextDrawTextSize(playerid, ProgressBar[playerid], INITITAL_BAR_SIZE, 0.000000);
 PlayerTextDrawShow(playerid, ProgressBar[playerid]);

 format(Loading_TempStr, sizeof Loading_TempStr, "%i seconds remaining", seconds);

 ProgressSec[playerid] =
 CreatePlayerTextDraw(playerid, 619.000000, 334.000000, Loading_TempStr);
 PlayerTextDrawAlignment(playerid, ProgressSec[playerid], 3);
 PlayerTextDrawBackgroundColor(playerid, ProgressSec[playerid], 255);
 PlayerTextDrawFont(playerid, ProgressSec[playerid], 1);
 PlayerTextDrawLetterSize(playerid, ProgressSec[playerid], 0.339999, 1.300000);
 PlayerTextDrawColor(playerid, ProgressSec[playerid], 255);
 PlayerTextDrawSetOutline(playerid, ProgressSec[playerid], 0);
 PlayerTextDrawSetProportional(playerid, ProgressSec[playerid], 1);
 PlayerTextDrawSetShadow(playerid, ProgressSec[playerid], 0);
 PlayerTextDrawShow(playerid, ProgressSec[playerid]);

 ProgressPer[playerid] =
 CreatePlayerTextDraw(playerid, 527.000000, 315.000000, "0%");
 PlayerTextDrawAlignment(playerid, ProgressPer[playerid], 2);
 PlayerTextDrawBackgroundColor(playerid, ProgressPer[playerid], 255);
 PlayerTextDrawFont(playerid, ProgressPer[playerid], 2);
 PlayerTextDrawLetterSize(playerid, ProgressPer[playerid], 0.400000, 1.400000);
 PlayerTextDrawColor(playerid, ProgressPer[playerid], -1);
 PlayerTextDrawSetOutline(playerid, ProgressPer[playerid], 0);
 PlayerTextDrawSetProportional(playerid, ProgressPer[playerid], 1);
 PlayerTextDrawSetShadow(playerid, ProgressPer[playerid], 1);
 PlayerTextDrawShow(playerid, ProgressPer[playerid]);

 Loading_Progress[playerid] = 0;
 Loading_EndCount[playerid] = seconds;
 Loading_Event[playerid] = eventid;
 Loading_Timer[playerid] = SetTimerEx("LoadingHandler", 1000, true, "d", playerid);
 return true;
}

forward StopProgressBar(playerid);
public StopProgressBar(playerid)
{
 Loading_Progress[playerid] = 0;
 Loading_EndCount[playerid] = 0;
 Loading_Event[playerid] = 0;
 TextDrawHideForPlayer(playerid, ProgressBG);
 PlayerTextDrawDestroy(playerid, ProgressBar[playerid]);
 PlayerTextDrawDestroy(playerid, ProgressSec[playerid]);
 PlayerTextDrawDestroy(playerid, ProgressPer[playerid]);
 PlayerTextDrawDestroy(playerid, ProgressTex[playerid]);
 KillTimer(Loading_Timer[playerid]);
 return true;
}

forward LoadingHandler(playerid);
public LoadingHandler(playerid)
{
 Loading_Progress[playerid]++;

 new Float:Percentage = floatdiv(Loading_Progress[playerid], Loading_EndCount[playerid]) * 100;
 format(Loading_TempStr, sizeof Loading_TempStr, "%.0f%%", Percentage);
 PlayerTextDrawSetString(playerid, ProgressPer[playerid], Loading_TempStr);

 if((Loading_EndCount[playerid] - Loading_Progress[playerid]) > 1)
  format(Loading_TempStr, sizeof Loading_TempStr, "%i seconds remaining",
 Loading_EndCount[playerid] - Loading_Progress[playerid]);
 else format(Loading_TempStr, sizeof Loading_TempStr, "1 second remaining");

 PlayerTextDrawSetString(playerid, ProgressSec[playerid], Loading_TempStr);

 PlayerTextDrawTextSize(playerid, ProgressBar[playerid],
 INITITAL_BAR_SIZE + ((FINAL_BAR_SIZE-INITITAL_BAR_SIZE)*(Percentage/100)),0);
 PlayerTextDrawShow(playerid, ProgressBar[playerid]);

 if(Percentage <= 100)
  CallLocalFunction("OnLoadingStateChange", "iiif", playerid,
 Loading_Event[playerid], Loading_EndCount[playerid] - Loading_Progress[playerid], Percentage);

 if(Loading_Progress[playerid] >= Loading_EndCount[playerid])
 {
  PlayerTextDrawSetShadow(playerid, ProgressSec[playerid], 1);
  PlayerTextDrawColor(playerid, ProgressSec[playerid], 0x00FF00FF);
  format(Loading_TempStr, sizeof Loading_TempStr, "Completed!");
  PlayerTextDrawSetString(playerid, ProgressSec[playerid], Loading_TempStr);
  PlayerTextDrawShow(playerid, ProgressSec[playerid]);

  KillTimer(Loading_Timer[playerid]);
  Loading_Timer[playerid] = SetTimerEx("StopProgressBar", 1000, false, "d", playerid);
 }

 return true;
}

forward OnLoadingStateChange(playerid, eventid, seconds_remaining, Float:percentage);
public OnLoadingStateChange(playerid, eventid, seconds_remaining, Float:percentage)
{
 new string[128],plname[MAX_PLAYER_NAME];
 GetPlayerName(playerid,plname,sizeof(plname));

 if(percentage < 100) return true;
 switch(eventid)
 {
  case TURF_TEST:
  {
   format(string, sizeof(string), "Captured turf succesefully. You have received +2500$ and 2 score.");
   SendClientMessage(playerid,0x208FFFC8,string);
  }
 }
 return true;
}

 

Revise this Paste

Your Name: Code Language: