Explica melhor,por partes ai.
PHP код:
enum ZXP
{
pEXP
};
// ~~> Config. Experience
new Text:TDXP[1];
new Point[MAX_PLAYERS][ZXP];
new Bar:BARXP[MAX_PLAYERS];
// ~~> Forwards
forward GetValueXP(playerid);
forward Experience(playerid, value);
public OnGameModeInit()
{
SetTimer("Experience", 1000, true);
SetTimer("UpdateBar", 1000, true);
// ~~> Contagem de XP
TDXP[0] = TextDrawCreate(575.507934, 57.164325, "1000/9000");
TextDrawAlignment(TDXP[0], 2);
TextDrawBackgroundColor(TDXP[0], 16);
TextDrawFont(TDXP[0], 2);
TextDrawLetterSize(TDXP[0], 0.150156, 0.595465);
TextDrawColor(TDXP[0], 0xCD0000FF);
TextDrawSetOutline(TDXP[0], 1);
TextDrawSetProportional(TDXP[0], 1);
TextDrawSetSelectable(TDXP[0], 0);
return true;
}
public OnPlayerRequestClass(playerid, classid)
{
Experience(playerid, 0);
return 1;
}
public OnPlayerSpawn(playerid)
{
// ~~ EXP
Experience(playerid, 0);
BARXP[playerid] = CreateProgressBar(548.00, 58.00, 57.50, 4.19, -492364374, 100.0);
TextDrawShowForPlayer(playerid, TDXP[0]);
ShowProgressBarForPlayer(playerid, BARXP[playerid]);
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
Player[playerid][Died]++;
Player[killerid][Killed]++;
SendDeathMessage(killerid, playerid, reason);
if(killerid != INVALID_PLAYER_ID)
{
if(IsPlayerConnected(killerid))
{
if(Player[playerid][pXOne] && Player[killerid][pXOne])
{
Player[playerid][pXOne] = false;
Player[killerid][pXOne] = false;
SetPlayerVirtualWorld(playerid, 0);
SetPlayerVirtualWorld(killerid, 0);
SetPlayerInterior(playerid, 0);
SetPlayerInterior(killerid, 0);
SendFormattedMessage(killerid, COLOR_TEAL, ""TAG_SERVER" Vocк venceu o player %s no X1.", GetName(playerid));
SendFormattedMessage(playerid, COLOR_TEAL, ""TAG_SERVER" Vocк perdeu para o player %s no X1.", GetName(killerid));
Player[killerid][XOneWin]++;
SpawnPlayer(killerid);
SpawnPlayer(playerid);
}
Experience(killerid, 4);
GivePlayerMoney(killerid, 100);
PlayerPlaySound(killerid, 1057, 0.0, 0.0, 0.0);
GameTextForPlayer(killerid, "DOUBLE XP!!~n~VOCE GANHOU 4 XP!!!!", 3000, 3);
UpdateBar(killerid);
}
}
return 1;
}
public GetValueXP(playerid)
{
static value;
if(Player[playerid][Score] == 0)
value = 4;
else
value = Player[playerid][Score] * 8;
return value;
}
//==============================================================================
public Experience(playerid, value)
{
Point[playerid][pEXP] += value;
if(Point[playerid][pEXP] >= GetValueXP(playerid))
{
Point[playerid][pEXP] = 0;
Player[playerid][Score] += 1;
SetPlayerScore(playerid, Player[playerid][Score]);
GameTextForPlayer(playerid, "~y~VOCE UPOU DE LEVEL!!!!", 3000, 3);
SetProgressBarValue(BARXP[playerid],0);
UpdateBar(playerid);
Salvar_Conta(playerid);
return 1;
}
UpdateBar(playerid);
return 1;
}
//==============================================================================
forward UpdateBar(playerid);
public UpdateBar(playerid)
{
SetProgressBarValue(BARXP[playerid], Point[playerid][pEXP]);
SetProgressBarMaxValue(BARXP[playerid], GetValueXP(playerid));
UpdateProgressBar(BARXP[playerid], playerid);
new str[100];
format(str, sizeof(str), "%d/%d", Point[playerid][pEXP], GetValueXP(playerid));
TextDrawSetString(TDXP[0], str);
return 1;
}