[Ajuda] Sistema EXP
#1

Explicaзгo: Bom meu sistema de exp tб com um problema que tipo quando upo a progress bar nгo reinicia do 0 й tambйm tipo se eu to com 4 de exp й precisso de 5 xp pra upar ai vo mata um player que no caso cada kill vale 4exp ai eu mato й upo mais nгo reinicia a progress й tambйm n da + 3 de exp pq usei so 1 de exp pra bater 5/5 cade os outros 3 ? devia reinicia a barra da progress + os 3 xp que ganhei por que so usei 1 de exp pra upa.

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(playeridvalue);
public 
OnGameModeInit()
{
SetTimer("Experience"1000true);
SetTimer("UpdateBar"1000true);
// ~~> Contagem de XP
    
TDXP[0] = TextDrawCreate(575.50793457.164325"1000/9000");
    
TextDrawAlignment(TDXP[0], 2);
    
TextDrawBackgroundColor(TDXP[0], 16);
    
TextDrawFont(TDXP[0], 2);
    
TextDrawLetterSize(TDXP[0], 0.1501560.595465);
    
TextDrawColor(TDXP[0], 0xCD0000FF);
    
TextDrawSetOutline(TDXP[0], 1);
    
TextDrawSetProportional(TDXP[0], 1);
    
TextDrawSetSelectable(TDXP[0], 0);
return 
true;
}
public 
OnPlayerRequestClass(playeridclassid)
{
Experience(playerid0);
return 
1;
}
public 
OnPlayerSpawn(playerid)
{
// ~~ EXP
    
Experience(playerid0);
    
BARXP[playerid] = CreateProgressBar(548.0058.0057.504.19, -492364374100.0);
    
TextDrawShowForPlayer(playeridTDXP[0]);
    
ShowProgressBarForPlayer(playeridBARXP[playerid]);
return 
1;
}
public 
OnPlayerDeath(playeridkilleridreason)
{
    
Player[playerid][Died]++;
    
Player[killerid][Killed]++;
    
SendDeathMessage(killeridplayeridreason);
    if(
killerid != INVALID_PLAYER_ID)
    {
        if(
IsPlayerConnected(killerid))
        {
            if(
Player[playerid][pXOne] && Player[killerid][pXOne])
            {
                
Player[playerid][pXOne] = false;
                
Player[killerid][pXOne] = false;
                
SetPlayerVirtualWorld(playerid0);
                
SetPlayerVirtualWorld(killerid0);
                
SetPlayerInterior(playerid0);
                
SetPlayerInterior(killerid0);
                
SendFormattedMessage(killeridCOLOR_TEAL""TAG_SERVER" Vocк venceu o player %s no X1."GetName(playerid));
                
SendFormattedMessage(playeridCOLOR_TEAL""TAG_SERVER" Vocк perdeu para o player %s no X1."GetName(killerid));
                
Player[killerid][XOneWin]++;
                
SpawnPlayer(killerid);
                
SpawnPlayer(playerid);
            }
            
Experience(killerid4);
            
GivePlayerMoney(killerid100);
            
PlayerPlaySound(killerid10570.00.00.0);
            
GameTextForPlayer(killerid"DOUBLE XP!!~n~VOCE GANHOU 4 XP!!!!"30003);
            
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(playeridvalue)
{
    
Point[playerid][pEXP] += value;
    if(
Point[playerid][pEXP] >= GetValueXP(playerid))
    {
        
Point[playerid][pEXP] = 0;
        
Player[playerid][Score] += 1;
        
SetPlayerScore(playeridPlayer[playerid][Score]);
        
GameTextForPlayer(playerid"~y~VOCE UPOU DE LEVEL!!!!"30003);
        
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(strsizeof(str), "%d/%d"Point[playerid][pEXP], GetValueXP(playerid));
    
TextDrawSetString(TDXP[0], str);
    return 
1;

Alguйm ajuda.
Reply
#2

Mano sу entendi essa parte :
Quote:

Bom meu sistema de exp tб com um problema que tipo quando upo a progress bar nгo reinicia do 0

Explica melhor,por partes ai.
Veja se a progress bar vai reiniciar agora :
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(playeridvalue); 
public 
OnGameModeInit() 

    
SetTimer("Experience"1000true); 
    
SetTimer("UpdateBar"1000true); 
// ~~> Contagem de XP 
    
TDXP[0] = TextDrawCreate(575.50793457.164325"1000/9000"); 
    
TextDrawAlignment(TDXP[0], 2); 
    
TextDrawBackgroundColor(TDXP[0], 16); 
    
TextDrawFont(TDXP[0], 2); 
    
TextDrawLetterSize(TDXP[0], 0.1501560.595465); 
    
TextDrawColor(TDXP[0], 0xCD0000FF); 
    
TextDrawSetOutline(TDXP[0], 1); 
    
TextDrawSetProportional(TDXP[0], 1); 
    
TextDrawSetSelectable(TDXP[0], 0); 
    return 
true

public 
OnPlayerRequestClass(playeridclassid

    
Experience(playerid0); 
    return 
1

public 
OnPlayerSpawn(playerid

// ~~ EXP 
    
Experience(playerid0); 
    
BARXP[playerid] = CreateProgressBar(548.0058.0057.504.19, -492364374100.0); 
    
TextDrawShowForPlayer(playeridTDXP[0]); 
    
ShowProgressBarForPlayer(playeridBARXP[playerid]); 
    return 
1

public 
OnPlayerDeath(playeridkilleridreason

    
Player[playerid][Died]++; 
    
Player[killerid][Killed]++; 
    
SendDeathMessage(killeridplayeridreason); 
    if(
killerid != INVALID_PLAYER_ID
    { 
        if(
IsPlayerConnected(killerid)) 
        { 
            if(
Player[playerid][pXOne] && Player[killerid][pXOne]) 
            { 
                
Player[playerid][pXOne] = false
                
Player[killerid][pXOne] = false
                
SetPlayerVirtualWorld(playerid0); 
                
SetPlayerVirtualWorld(killerid0); 
                
SetPlayerInterior(playerid0); 
                
SetPlayerInterior(killerid0); 
                
SendFormattedMessage(killeridCOLOR_TEAL""TAG_SERVER" Vocк venceu o player %s no X1."GetName(playerid)); 
                
SendFormattedMessage(playeridCOLOR_TEAL""TAG_SERVER" Vocк perdeu para o player %s no X1."GetName(killerid)); 
                
Player[killerid][XOneWin]++; 
                
SpawnPlayer(killerid); 
                
SpawnPlayer(playerid); 
            } 
            
Experience(killerid4); 
            
GivePlayerMoney(killerid100); 
            
PlayerPlaySound(killerid10570.00.00.0); 
            
GameTextForPlayer(killerid"DOUBLE XP!!~n~VOCE GANHOU 4 XP!!!!"30003); 
            
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(playeridvalue

    
Point[playerid][pEXP] += value
    if(
Point[playerid][pEXP] >= GetValueXP(playerid)) 
    { 
        
Point[playerid][pEXP] = 0
        
Player[playerid][Score] += 1
        
SetPlayerScore(playeridPlayer[playerid][Score]); 
        
GameTextForPlayer(playerid"~y~VOCE UPOU DE LEVEL!!!!"30003); 
        
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(strsizeof(str), "%d/%d"Point[playerid][pEXP], GetValueXP(playerid)); 
    
TextDrawSetString(TDXP[0], str); 
    return 
1

Reply
#3

Quote:
Originally Posted by FerrariL
Посмотреть сообщение
Mano sу entendi essa parte :
Explica melhor,por partes ai.
Veja se a progress bar vai reiniciar agora :
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(playeridvalue); 
public 
OnGameModeInit() 

    
SetTimer("Experience"1000true); 
    
SetTimer("UpdateBar"1000true); 
// ~~> Contagem de XP 
    
TDXP[0] = TextDrawCreate(575.50793457.164325"1000/9000"); 
    
TextDrawAlignment(TDXP[0], 2); 
    
TextDrawBackgroundColor(TDXP[0], 16); 
    
TextDrawFont(TDXP[0], 2); 
    
TextDrawLetterSize(TDXP[0], 0.1501560.595465); 
    
TextDrawColor(TDXP[0], 0xCD0000FF); 
    
TextDrawSetOutline(TDXP[0], 1); 
    
TextDrawSetProportional(TDXP[0], 1); 
    
TextDrawSetSelectable(TDXP[0], 0); 
    return 
true

public 
OnPlayerRequestClass(playeridclassid

    
Experience(playerid0); 
    return 
1

public 
OnPlayerSpawn(playerid

// ~~ EXP 
    
Experience(playerid0); 
    
BARXP[playerid] = CreateProgressBar(548.0058.0057.504.19, -492364374100.0); 
    
TextDrawShowForPlayer(playeridTDXP[0]); 
    
ShowProgressBarForPlayer(playeridBARXP[playerid]); 
    return 
1

public 
OnPlayerDeath(playeridkilleridreason

    
Player[playerid][Died]++; 
    
Player[killerid][Killed]++; 
    
SendDeathMessage(killeridplayeridreason); 
    if(
killerid != INVALID_PLAYER_ID
    { 
        if(
IsPlayerConnected(killerid)) 
        { 
            if(
Player[playerid][pXOne] && Player[killerid][pXOne]) 
            { 
                
Player[playerid][pXOne] = false
                
Player[killerid][pXOne] = false
                
SetPlayerVirtualWorld(playerid0); 
                
SetPlayerVirtualWorld(killerid0); 
                
SetPlayerInterior(playerid0); 
                
SetPlayerInterior(killerid0); 
                
SendFormattedMessage(killeridCOLOR_TEAL""TAG_SERVER" Vocк venceu o player %s no X1."GetName(playerid)); 
                
SendFormattedMessage(playeridCOLOR_TEAL""TAG_SERVER" Vocк perdeu para o player %s no X1."GetName(killerid)); 
                
Player[killerid][XOneWin]++; 
                
SpawnPlayer(killerid); 
                
SpawnPlayer(playerid); 
            } 
            
Experience(killerid4); 
            
GivePlayerMoney(killerid100); 
            
PlayerPlaySound(killerid10570.00.00.0); 
            
GameTextForPlayer(killerid"DOUBLE XP!!~n~VOCE GANHOU 4 XP!!!!"30003); 
            
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(playeridvalue

    
Point[playerid][pEXP] += value
    if(
Point[playerid][pEXP] >= GetValueXP(playerid)) 
    { 
        
Point[playerid][pEXP] = 0
        
Player[playerid][Score] += 1
        
SetPlayerScore(playeridPlayer[playerid][Score]); 
        
GameTextForPlayer(playerid"~y~VOCE UPOU DE LEVEL!!!!"30003); 
        
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(strsizeof(str), "%d/%d"Point[playerid][pEXP], GetValueXP(playerid)); 
    
TextDrawSetString(TDXP[0], str); 
    return 
1

Bom vou tenta explica melhor, tipo sou nivel 1 й to quase upando pro nivel 2 minhaa quantidade de exp tб 4/5 precisso de 1 exp entгo pra upa certo, ai vou й mato um player й quando eu mato um player ganho 4 + de exp ai tipo matei um player deu 5/5 ent devia reinicia a barra da progress й me da + 3 de exp na nova barra por consumi so 1 exp dos 4 que ganhei por mata o player.
Reply
#4

PHP код:
public Experience(playeridvalue

    
Point[playerid][pEXP] += value
    if(
Point[playerid][pEXP] >= GetValueXP(playerid)) 
    { 
        
Point[playerid][pEXP] = 0
        
Player[playerid][Score] += 1
        
SetProgressBarValue(BARXP[playerid], 0); 
        
SetProgressBarMaxValue(BARXP[playerid], GetValueXP(playerid)); 
        
SetPlayerScore(playeridPlayer[playerid][Score]); 
        
GameTextForPlayer(playerid"~y~VOCE UPOU DE LEVEL!!!!"30003); 
        
Salvar_Conta(playerid); 
        return 
1
    } 
    
UpdateBar(playerid); 
    return 
1

...
PS: Nгo intendo muito sobre .
Reply
#5

continua da mesma forma.
Reply
#6

Ela so acrescenta e nгo reseta ?
Voзк quer que ela de reset ao subir de nivel ?
Reply
#7

Bom, pelo oque eu entendi vocк precisa usar matemбtica simples, teste:

Код HTML:
stock Experience(playerid, value)
{
	Point[playerid][pEXP] += value;
	new exp = GetValueXP(playerid);

	if(Point[playerid][pEXP] >= exp)
	{
            SetPlayerScore(playerid, ++Player[playerid][Score]);

	    new tmp = (Point[playerid][pEXP] - exp);
            Point[playerid][pEXP] = tmp;  
            SetProgressBarMaxValue(BARXP[playerid], GetValueXP(playerid));
            SetProgressBarValue(BARXP[playerid], tmp); 

            GameTextForPlayer(playerid, "~y~VOCE UPOU DE LEVEL!!!!", 3000, 3);
            Salvar_Conta(playerid);  
	}
	else SetProgressBarValue(BARXP[playerid], Point[playerid][pEXP]);
	return 1;
}
Reply
#8

Quote:
Originally Posted by Don_Speed
Посмотреть сообщение
Ela so acrescenta e nгo reseta ?
Voзк quer que ela de reset ao subir de nivel ?
isso й comeзa uma nova barra de progress
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)