Salut, am si eu o 'problema' cu un cod de ProgressBar. E pe baza de exp si atunci cand ating (100+/100) se reseteaza la 0. Vreau ca atunci cand fac de ex. 200/100 sa faca level up si sa imi ramana 100/200 (pentru urmatorul level).
function giveExp(playerid, expAmount) {
new
exp_String[64],
szStr[128],
query[100];
if(!expAmount) expAmount = 1;
PlayerInfo[playerid][pExp] += expAmount;
SCMf(playerid, -1, "{ffffff}Ai primit %d puncte de experienta (total %d).",expAmount,PlayerInfo[playerid][pExp]);
format(exp_String,64,"~g~+%d EXPERIENCE",expAmount);
GameTextForPlayer(playerid,exp_String,3000,1);
if(PlayerInfo[playerid][pExp] >= PlayerInfo[playerid][pNeedExp]) {
PlayerInfo[playerid][pExp] = 0;
UpdateProgress(playerid);
PlayerInfo[playerid][pNeedExp] = PlayerInfo[playerid][pNeedExp] + 100;
PlayerInfo[playerid][pLevel] ++;
SetPlayerScore(playerid,PlayerInfo[playerid][pLevel]);
UpdateProgress(playerid);
mysql_format(SQL, query, 100, "UPDATE `users` SET `Level` = '%d' WHERE `ID` = '%d' LIMIT 1", PlayerInfo[playerid][pLevel], PlayerInfo[playerid][pSQLID]);
mysql_tquery(SQL, query, "", "");
Update(playerid, pNeedExpx);
format(szStr, sizeof szStr,"Ai avansat la level {ffffff}%d{25a869} deoarece ai acumulat destula experienta.",PlayerInfo[playerid][pLevel]);
SCM(playerid, 0x25a869FF, szStr);
}
return true;
}
function UpdateProgress(playerid) {
new string[512];
format(string, sizeof(string), "Level: %d (%d/%d Exp)", PlayerInfo[playerid][pLevel], PlayerInfo[playerid][pExp], PlayerInfo[playerid][pNeedExp]);
PlayerTextDrawSetString(playerid, HudBarTD, string);
PlayerTextDrawShow(playerid, HudBarTD);
SetPlayerProgressBarMaxValue(playerid, HudProgress[playerid], PlayerInfo[playerid][pNeedExp]);
SetPlayerProgressBarValue(playerid, HudProgress[playerid], PlayerInfo[playerid][pExp]);
SetPlayerProgressBarColour(playerid, HudProgress[playerid], COLOR_SVORANGE);
ShowPlayerProgressBar(playerid, HudProgress[playerid]);
return 1;
}