[Ajuda] Setar informaзoes do player ao logar
#1

Boa tarde galera, quando o player desloga(/quit) do servidor salva a conta tudo certinho, e ao logar novamente no servidor nгo seta todas as info do player, sу seta "Logou", "Matou", "Morreu", e ficam faltando as info "Level", "Dinheiro".

Aqui й uma parte do dialog login, apos o player inserir a senha corretamente.

Код:
 PlayerInfo[playerid][pSenha] = DOF2_GetInt(arquivo, "Senha");
            if(strval(inputtext) == PlayerInfo[playerid][pSenha])
            {
                SetarPlayer(playerid);
                PlayerInfo[playerid][pLogou]++;
                SpawnPlayer(playerid);
            }
E aqui a funзгo pra setar as info do player ao logar.

Код:
 SetarPlayer(playerid)
{
    
	new String[256], name[MAX_PLAYER_NAME];
	GetPlayerName(playerid, name, 32);
	format(String, 40, "Contas/%s.ini", name);
    
    SetPlayerScore(playerid, PlayerInfo[playerid][pScore]);
    GivePlayerMoney(playerid, PlayerInfo[playerid][pDinheiro]);
    
   	PlayerInfo[playerid][pScore] = DOF2_GetInt(String,"Level");
	PlayerInfo[playerid][pDinheiro] = DOF2_GetInt(String,"Dinheiro");
	PlayerInfo[playerid][pLogou] = DOF2_GetInt(String, "Logou");
	PlayerInfo[playerid][pMatou] = DOF2_GetInt(String, "Matou");
	PlayerInfo[playerid][pMorreu] = DOF2_GetInt(String, "Morreu");
	
	DOF2_SaveFile();
	return 1;
}
Reply
#2

quando o Player sai esta salvando as info?
Quote:

public OnPlayerDisconnect(playerid, reason)

Reply
#3

Quote:
Originally Posted by IgorLuiz
Посмотреть сообщение
quando o Player sai esta salvando as info?
Sim, salva tudo certinho: Level, Dinheiro, Matou, Morreu e Logou.
Quando volta ao servidor sу seta in-game as seguintes info: matou, morreu e logou;
Ja Level e Dinheiro zeram e comeзam do 0 novamente.
Reply
#4

Quote:
Originally Posted by cicinho
Посмотреть сообщение
Sim, salva tudo certinho: Level, Dinheiro, Matou, Morreu e Logou.
Quando volta ao servidor sу seta in-game as seguintes info: matou, morreu e logou;
Ja Level e Dinheiro zeram e comeзam do 0 novamente.
muda esse stock para essa

Код:
 SetarPlayer(playerid)
{

	new String[256], name[MAX_PLAYER_NAME];
	GetPlayerName(playerid, name, 32);
	format(String, 40, "Contas/%s.ini", name);

    GetPlayerScore(playerid, PlayerInfo[playerid][pScore]);
    GetPlayerMoney(playerid, PlayerInfo[playerid][pDinheiro]);

   	PlayerInfo[playerid][pScore] = DOF2_GetInt(String,"Level");
	PlayerInfo[playerid][pDinheiro] = DOF2_GetInt(String,"Dinheiro");
	PlayerInfo[playerid][pLogou] = DOF2_GetInt(String, "Logou");
	PlayerInfo[playerid][pMatou] = DOF2_GetInt(String, "Matou");
	PlayerInfo[playerid][pMorreu] = DOF2_GetInt(String, "Morreu");

	DOF2_SaveFile();
	return 1;
}
Reply
#5

Quote:
Originally Posted by IgorLuiz
Посмотреть сообщение
muda esse stock para essa

Код:
 SetarPlayer(playerid)
{

	new String[256], name[MAX_PLAYER_NAME];
	GetPlayerName(playerid, name, 32);
	format(String, 40, "Contas/%s.ini", name);

    GetPlayerScore(playerid, PlayerInfo[playerid][pScore]);
    GetPlayerMoney(playerid, PlayerInfo[playerid][pDinheiro]);

   	PlayerInfo[playerid][pScore] = DOF2_GetInt(String,"Level");
	PlayerInfo[playerid][pDinheiro] = DOF2_GetInt(String,"Dinheiro");
	PlayerInfo[playerid][pLogou] = DOF2_GetInt(String, "Logou");
	PlayerInfo[playerid][pMatou] = DOF2_GetInt(String, "Matou");
	PlayerInfo[playerid][pMorreu] = DOF2_GetInt(String, "Morreu");

	DOF2_SaveFile();
	return 1;
}
Porque vc cria uma string com 256 cйlulas e depois formata ela com sу 40 ? O.o
Reply
#6

Quote:
Originally Posted by Cleyson
Посмотреть сообщение
Porque vc cria uma string com 256 cйlulas e depois formata ela com sу 40 ? O.o
Apenas adapetei isso amigo!
Код:
    GetPlayerScore(playerid, PlayerInfo[playerid][pScore]);
    GetPlayerMoney(playerid, PlayerInfo[playerid][pDinheiro]);
o resto e dele mesmo
Reply
#7

Entгo o correto й:


PHP код:
SetarPlayer(playerid)
{
    new 
String[70], name[MAX_PLAYER_NAME];
    
GetPlayerName(playeridname32);
    
format(String70"Contas/%s.ini"name);
   
PlayerInfo[playerid][pScore] = DOF2_GetInt(String,"Level");
    
PlayerInfo[playerid][pDinheiro] = DOF2_GetInt(String,"Dinheiro");
    
PlayerInfo[playerid][pLogou] = DOF2_GetInt(String"Logou");
    
PlayerInfo[playerid][pMatou] = DOF2_GetInt(String"Matou");
    
PlayerInfo[playerid][pMorreu] = DOF2_GetInt(String"Morreu");
    
SetPlayerScore(playeridPlayerInfo[playerid][pScore]);
    
GivePlayerMoney(playeridPlayerInfo[playerid][pDinheiro]);
    
    return 
1;

Reply
#8

Vlw vcs 2 pela ajuda tudo certoooo

rep+
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)