[Ajuda] Zerando Dinheiro do Player
#1

Olб pessoal, tudo bem com vocкs? Eu estou уtimo, porem com uma duvida.
Fiz meu sistema de salvamento tudo bonitinho, porem as vezes de maneira que o player entra e sai do servidor, o dinheiro cai pra zero, assim do nada, por exemplo, deslogo com $500,00 na mгo quando relogo esta com $00,00!

O que pode ser? e alguma ideia de como resolver?

Vou colocar o sistema de salvamento:
PHP код:
public OnPlayerDisconnect(playeridreason)
{
    
SalvarDados(playerid);
    return 
1;
}
stock SalvarDados(playerid)
{
        
DOF2_SetInt(OnPlayerAccount(playerid), "Level"GetPlayerScore(playerid));
        
DOF2_SetInt(OnPlayerAccount(playerid), "Skin"GetPlayerSkin(playerid));
    
DOF2_SetInt(OnPlayerAccount(playerid), "Kills"PlayerInfo[playerid][pKills]);
    
DOF2_SetInt(OnPlayerAccount(playerid), "Deaths"PlayerInfo[playerid][pDeaths]);
    
DOF2_SetInt(OnPlayerAccount(playerid), "Money"GetPlayerMoney(playerid));
    
DOF2_SetInt(OnPlayerAccount(playerid), "Advertencias"PlayerInfo[playerid][pAdvertencias]);
    
DOF2_SetInt(OnPlayerAccount(playerid), "Preso"PlayerInfo[playerid][pPreso]);
     
DOF2_SetInt(OnPlayerAccount(playerid), "Cargo"PlayerInfo[playerid][pCargo]);
        
DOF2_SetInt(OnPlayerAccount(playerid), "Membro"PlayerInfo[playerid][pMembro]);
        
DOF2_SetInt(OnPlayerAccount(playerid), "Lider"PlayerInfo[playerid][pLider]);
        
DOF2_SetInt(OnPlayerAccount(playerid), "Idade"PlayerInfo[playerid][pIdade]);
        
DOF2_SetInt(OnPlayerAccount(playerid), "SubLider"PlayerInfo[playerid][pSubLider]);
    
DOF2_SetString(OnPlayerAccount(playerid), "IP"PlayerIp(playerid));
     
DOF2_SetInt(OnPlayerAccount(playerid), "Wanted"GetPlayerWantedLevel(playerid));
     
DOF2_SetInt(OnPlayerBank(playerid), "Saldo"PlayerInfo[playerid][pBank]);
    
DOF2_SaveFile();
    return 
1;
}
stock CarregarContas(playerid)
{
    
SetPlayerScore(playeridDOF2_GetInt(OnPlayerAccount(playerid), "Level"));
    
GivePlayerMoney(playeridDOF2_GetInt(OnPlayerAccount(playerid), "Money"));
    
PlayerInfo[playerid][pBank] = DOF2_GetInt(OnPlayerBank(playerid), "Saldo");
    
SetPlayerWantedLevel(playeridDOF2_GetInt(OnPlayerAccount(playerid), "Wanted"));
    
SetPlayerHealth(playeridDOF2_GetFloat(OnPlayerAccount(playerid), "Health"));
    
SetPlayerArmour(playeridDOF2_GetFloat(OnPlayerAccount(playerid), "Armour"));
    
SetPlayerSkin(playeridDOF2_GetInt(OnPlayerAccount(playerid), "Skin"));
    
DOF2_GetString(OnPlayerAccount(playerid), "Sexo");
    
DOF2_GetInt(OnPlayerAccount(playerid), "Idade"PlayerInfo[playerid][pIdade]);
    
PlayerInfo[playerid][pKills] = DOF2_GetInt(OnPlayerAccount(playerid), "Kills");
    
PlayerInfo[playerid][pDeaths] = DOF2_GetInt(OnPlayerAccount(playerid), "Deaths");
    
PlayerInfo[playerid][pLider] = DOF2_GetInt(OnPlayerAccount(playerid), "Lider");
    
PlayerInfo[playerid][pSubLider] = DOF2_GetInt(OnPlayerAccount(playerid), "SubLider");
    
PlayerInfo[playerid][pMembro] = DOF2_GetInt(OnPlayerAccount(playerid), "Membro");
    
PlayerInfo[playerid][pCargo] = DOF2_GetInt(OnPlayerAccount(playerid), "Cargo");
    
DOF2_GetInt(OnPlayerAccount(playerid), "Advertencias"PlayerInfo[playerid][pAdvertencias]);
    
DOF2_GetInt(OnPlayerAccount(playerid), "Calado"PlayerInfo[playerid][pCalado]);
    
DOF2_GetInt(OnPlayerAccount(playerid), "Preso"PlayerInfo[playerid][pPreso]);
    
SendClientMessage(playerid0xEAEF10AA"[SERVER] Dados Carregados com Sucesso!");F
    OnPlayerLogin
(playerid);
}
public 
TimeContas(playerid//Quando Player Loga й chamado este time para carregar os dados dele.
{
    
SetTimerEx("TimeContas2"200false"i"playerid);
}
public 
TimeContas2(playerid)
{
    
CarregarContas(playerid);
    return 
1;

Eu fiz alguma cagada?

Fiquem com Deus, um forte abraзo.
Aguardo ansiosamente cada um de vocкs.

Atenciosamente,
Matheus Dorado
Reply
#2

Nгo use as funзхes nativas do SA-MP para salvamento, elas sгo vulnerбveis a cheats.
PHP код:
new Cash[MAX_PLAYERS];
public 
OnPlayerDisconnect(playeridreason)
{
    
SalvarDados(playerid);
    return 
1;
}
stock SalvarDados(playerid)
{
    
DOF2_SetInt(OnPlayerAccount(playerid), "Level"GetPlayerScore(playerid));
     
DOF2_SetInt(OnPlayerAccount(playerid), "Skin"GetPlayerSkin(playerid));
    
DOF2_SetInt(OnPlayerAccount(playerid), "Kills"PlayerInfo[playerid][pKills]);
    
DOF2_SetInt(OnPlayerAccount(playerid), "Deaths"PlayerInfo[playerid][pDeaths]);
    
DOF2_SetInt(OnPlayerAccount(playerid), "Money"Cash[playerid]);
    
DOF2_SetInt(OnPlayerAccount(playerid), "Advertencias"PlayerInfo[playerid][pAdvertencias]);
    
DOF2_SetInt(OnPlayerAccount(playerid), "Preso"PlayerInfo[playerid][pPreso]);
    
DOF2_SetInt(OnPlayerAccount(playerid), "Cargo"PlayerInfo[playerid][pCargo]);
    
DOF2_SetInt(OnPlayerAccount(playerid), "Membro"PlayerInfo[playerid][pMembro]);
    
DOF2_SetInt(OnPlayerAccount(playerid), "Lider"PlayerInfo[playerid][pLider]);
    
DOF2_SetInt(OnPlayerAccount(playerid), "Idade"PlayerInfo[playerid][pIdade]);
    
DOF2_SetInt(OnPlayerAccount(playerid), "SubLider"PlayerInfo[playerid][pSubLider]);
    
DOF2_SetString(OnPlayerAccount(playerid), "IP"PlayerIp(playerid));
    
DOF2_SetInt(OnPlayerAccount(playerid), "Wanted"GetPlayerWantedLevel(playerid));
    
DOF2_SetInt(OnPlayerBank(playerid), "Saldo"PlayerInfo[playerid][pBank]);
    
DOF2_SaveFile();
    return 
1;
}
stock CarregarContas(playerid)
{
    
SetCash(playerid0); //Resetar variбvel por seguranзa
    
    
SetPlayerScore(playeridDOF2_GetInt(OnPlayerAccount(playerid), "Level"));
    
SetCash(playeridDOF2_GetInt(OnPlayerAccount(playerid), "Money"));
    
PlayerInfo[playerid][pBank] = DOF2_GetInt(OnPlayerBank(playerid), "Saldo");
    
SetPlayerWantedLevel(playeridDOF2_GetInt(OnPlayerAccount(playerid), "Wanted"));
    
SetPlayerHealth(playeridDOF2_GetFloat(OnPlayerAccount(playerid), "Health"));
    
SetPlayerArmour(playeridDOF2_GetFloat(OnPlayerAccount(playerid), "Armour"));
    
SetPlayerSkin(playeridDOF2_GetInt(OnPlayerAccount(playerid), "Skin"));
    
DOF2_GetString(OnPlayerAccount(playerid), "Sexo");
    
DOF2_GetInt(OnPlayerAccount(playerid), "Idade"PlayerInfo[playerid][pIdade]);
    
PlayerInfo[playerid][pKills] = DOF2_GetInt(OnPlayerAccount(playerid), "Kills");
    
PlayerInfo[playerid][pDeaths] = DOF2_GetInt(OnPlayerAccount(playerid), "Deaths");
    
PlayerInfo[playerid][pLider] = DOF2_GetInt(OnPlayerAccount(playerid), "Lider");
    
PlayerInfo[playerid][pSubLider] = DOF2_GetInt(OnPlayerAccount(playerid), "SubLider");
    
PlayerInfo[playerid][pMembro] = DOF2_GetInt(OnPlayerAccount(playerid), "Membro");
    
PlayerInfo[playerid][pCargo] = DOF2_GetInt(OnPlayerAccount(playerid), "Cargo");
    
DOF2_GetInt(OnPlayerAccount(playerid), "Advertencias"PlayerInfo[playerid][pAdvertencias]);
    
DOF2_GetInt(OnPlayerAccount(playerid), "Calado"PlayerInfo[playerid][pCalado]);
    
DOF2_GetInt(OnPlayerAccount(playerid), "Preso"PlayerInfo[playerid][pPreso]);
    
SendClientMessage(playerid0xEAEF10AA"[SERVER] Dados Carregados com Sucesso!");
    
    
GivePlayerMoney(playeridGetCash(playerid));
    
OnPlayerLogin(playerid);
}
public 
TimeContas(playerid//Quando Player Loga й chamado este time para carregar os dados dele.
{
    
SetTimerEx("TimeContas2"200false"i"playerid);
}
public 
TimeContas2(playerid)
{
    
CarregarContas(playerid);
    return 
1;
}
//Funзхes de dinheiro ----------------------------------------------------------
forward GiveCash(playeridamount);
public 
GiveCash(playeridamount)
{
    
Cash[playerid] += amount;
    
ResetPlayerMoney(playerid);
    
GivePlayerMoney(playeridCash[playerid]);
    return 
1;
}
forward SetCash(playeridamount);
public 
SetCash(playeridamount)
{
    
Cash[playerid] = amount;
    
ResetPlayerMoney(playerid);
    
GivePlayerMoney(playeridCash[playerid]);
    return 
1;
}
forward  GetCash(playerid);
public 
GetCash(playerid)
{
    return 
Cash[playerid];
}
//------------------------------------------------------------------------------ 
Agore use somente as funзхes SetCash, GiveCash e GetCash para manipular o dinheiro dos jogadores.
Reply
#3

Quote:
Originally Posted by RodrigoMSR
Посмотреть сообщение
Nгo use as funзхes nativas do SA-MP para salvamento, elas sгo vulnerбveis a cheats.
PHP код:
new Cash[MAX_PLAYERS];
public 
OnPlayerDisconnect(playeridreason)
{
    
SalvarDados(playerid);
    return 
1;
}
stock SalvarDados(playerid)
{
    
DOF2_SetInt(OnPlayerAccount(playerid), "Level"GetPlayerScore(playerid));
     
DOF2_SetInt(OnPlayerAccount(playerid), "Skin"GetPlayerSkin(playerid));
    
DOF2_SetInt(OnPlayerAccount(playerid), "Kills"PlayerInfo[playerid][pKills]);
    
DOF2_SetInt(OnPlayerAccount(playerid), "Deaths"PlayerInfo[playerid][pDeaths]);
    
DOF2_SetInt(OnPlayerAccount(playerid), "Money"Cash[playerid]);
    
DOF2_SetInt(OnPlayerAccount(playerid), "Advertencias"PlayerInfo[playerid][pAdvertencias]);
    
DOF2_SetInt(OnPlayerAccount(playerid), "Preso"PlayerInfo[playerid][pPreso]);
    
DOF2_SetInt(OnPlayerAccount(playerid), "Cargo"PlayerInfo[playerid][pCargo]);
    
DOF2_SetInt(OnPlayerAccount(playerid), "Membro"PlayerInfo[playerid][pMembro]);
    
DOF2_SetInt(OnPlayerAccount(playerid), "Lider"PlayerInfo[playerid][pLider]);
    
DOF2_SetInt(OnPlayerAccount(playerid), "Idade"PlayerInfo[playerid][pIdade]);
    
DOF2_SetInt(OnPlayerAccount(playerid), "SubLider"PlayerInfo[playerid][pSubLider]);
    
DOF2_SetString(OnPlayerAccount(playerid), "IP"PlayerIp(playerid));
    
DOF2_SetInt(OnPlayerAccount(playerid), "Wanted"GetPlayerWantedLevel(playerid));
    
DOF2_SetInt(OnPlayerBank(playerid), "Saldo"PlayerInfo[playerid][pBank]);
    
DOF2_SaveFile();
    return 
1;
}
stock CarregarContas(playerid)
{
    
SetCash(playerid0); //Resetar variбvel por seguranзa
    
    
SetPlayerScore(playeridDOF2_GetInt(OnPlayerAccount(playerid), "Level"));
    
SetCash(playeridDOF2_GetInt(OnPlayerAccount(playerid), "Money"));
    
PlayerInfo[playerid][pBank] = DOF2_GetInt(OnPlayerBank(playerid), "Saldo");
    
SetPlayerWantedLevel(playeridDOF2_GetInt(OnPlayerAccount(playerid), "Wanted"));
    
SetPlayerHealth(playeridDOF2_GetFloat(OnPlayerAccount(playerid), "Health"));
    
SetPlayerArmour(playeridDOF2_GetFloat(OnPlayerAccount(playerid), "Armour"));
    
SetPlayerSkin(playeridDOF2_GetInt(OnPlayerAccount(playerid), "Skin"));
    
DOF2_GetString(OnPlayerAccount(playerid), "Sexo");
    
DOF2_GetInt(OnPlayerAccount(playerid), "Idade"PlayerInfo[playerid][pIdade]);
    
PlayerInfo[playerid][pKills] = DOF2_GetInt(OnPlayerAccount(playerid), "Kills");
    
PlayerInfo[playerid][pDeaths] = DOF2_GetInt(OnPlayerAccount(playerid), "Deaths");
    
PlayerInfo[playerid][pLider] = DOF2_GetInt(OnPlayerAccount(playerid), "Lider");
    
PlayerInfo[playerid][pSubLider] = DOF2_GetInt(OnPlayerAccount(playerid), "SubLider");
    
PlayerInfo[playerid][pMembro] = DOF2_GetInt(OnPlayerAccount(playerid), "Membro");
    
PlayerInfo[playerid][pCargo] = DOF2_GetInt(OnPlayerAccount(playerid), "Cargo");
    
DOF2_GetInt(OnPlayerAccount(playerid), "Advertencias"PlayerInfo[playerid][pAdvertencias]);
    
DOF2_GetInt(OnPlayerAccount(playerid), "Calado"PlayerInfo[playerid][pCalado]);
    
DOF2_GetInt(OnPlayerAccount(playerid), "Preso"PlayerInfo[playerid][pPreso]);
    
SendClientMessage(playerid0xEAEF10AA"[SERVER] Dados Carregados com Sucesso!");
    
    
GivePlayerMoney(playeridGetCash(playerid));
    
OnPlayerLogin(playerid);
}
public 
TimeContas(playerid//Quando Player Loga й chamado este time para carregar os dados dele.
{
    
SetTimerEx("TimeContas2"200false"i"playerid);
}
public 
TimeContas2(playerid)
{
    
CarregarContas(playerid);
    return 
1;
}
//Funзхes de dinheiro ----------------------------------------------------------
forward GiveCash(playeridamount);
public 
GiveCash(playeridamount)
{
    
Cash[playerid] += amount;
    
ResetPlayerMoney(playerid);
    
GivePlayerMoney(playeridCash[playerid]);
    return 
1;
}
forward SetCash(playeridamount);
public 
SetCash(playeridamount)
{
    
Cash[playerid] = amount;
    
ResetPlayerMoney(playerid);
    
GivePlayerMoney(playeridCash[playerid]);
    return 
1;
}
forward  GetCash(playerid);
public 
GetCash(playerid)
{
    return 
Cash[playerid];
}
//------------------------------------------------------------------------------ 
Agore use somente as funзхes SetCash, GiveCash e GetCash para manipular o dinheiro dos jogadores.
Vlw Irmгo, vou testar tudinho, dai te dou uma resposta ok?
Muito obrigado pela sua ajuda, e obrigado pela informaзгo, eu nгo sabia dessa vulnerabilidade das funзхes nativas.
Um forte abraзo, atй jaja.
Reply
#4

Quote:
Originally Posted by RodrigoMSR
Посмотреть сообщение
Nгo use as funзхes nativas do SA-MP para salvamento, elas sгo vulnerбveis a cheats.
PHP код:
new Cash[MAX_PLAYERS];
public 
OnPlayerDisconnect(playeridreason)
{
    
SalvarDados(playerid);
    return 
1;
}
stock SalvarDados(playerid)
{
    
DOF2_SetInt(OnPlayerAccount(playerid), "Level"GetPlayerScore(playerid));
     
DOF2_SetInt(OnPlayerAccount(playerid), "Skin"GetPlayerSkin(playerid));
    
DOF2_SetInt(OnPlayerAccount(playerid), "Kills"PlayerInfo[playerid][pKills]);
    
DOF2_SetInt(OnPlayerAccount(playerid), "Deaths"PlayerInfo[playerid][pDeaths]);
    
DOF2_SetInt(OnPlayerAccount(playerid), "Money"Cash[playerid]);
    
DOF2_SetInt(OnPlayerAccount(playerid), "Advertencias"PlayerInfo[playerid][pAdvertencias]);
    
DOF2_SetInt(OnPlayerAccount(playerid), "Preso"PlayerInfo[playerid][pPreso]);
    
DOF2_SetInt(OnPlayerAccount(playerid), "Cargo"PlayerInfo[playerid][pCargo]);
    
DOF2_SetInt(OnPlayerAccount(playerid), "Membro"PlayerInfo[playerid][pMembro]);
    
DOF2_SetInt(OnPlayerAccount(playerid), "Lider"PlayerInfo[playerid][pLider]);
    
DOF2_SetInt(OnPlayerAccount(playerid), "Idade"PlayerInfo[playerid][pIdade]);
    
DOF2_SetInt(OnPlayerAccount(playerid), "SubLider"PlayerInfo[playerid][pSubLider]);
    
DOF2_SetString(OnPlayerAccount(playerid), "IP"PlayerIp(playerid));
    
DOF2_SetInt(OnPlayerAccount(playerid), "Wanted"GetPlayerWantedLevel(playerid));
    
DOF2_SetInt(OnPlayerBank(playerid), "Saldo"PlayerInfo[playerid][pBank]);
    
DOF2_SaveFile();
    return 
1;
}
stock CarregarContas(playerid)
{
    
SetCash(playerid0); //Resetar variбvel por seguranзa
    
    
SetPlayerScore(playeridDOF2_GetInt(OnPlayerAccount(playerid), "Level"));
    
SetCash(playeridDOF2_GetInt(OnPlayerAccount(playerid), "Money"));
    
PlayerInfo[playerid][pBank] = DOF2_GetInt(OnPlayerBank(playerid), "Saldo");
    
SetPlayerWantedLevel(playeridDOF2_GetInt(OnPlayerAccount(playerid), "Wanted"));
    
SetPlayerHealth(playeridDOF2_GetFloat(OnPlayerAccount(playerid), "Health"));
    
SetPlayerArmour(playeridDOF2_GetFloat(OnPlayerAccount(playerid), "Armour"));
    
SetPlayerSkin(playeridDOF2_GetInt(OnPlayerAccount(playerid), "Skin"));
    
DOF2_GetString(OnPlayerAccount(playerid), "Sexo");
    
DOF2_GetInt(OnPlayerAccount(playerid), "Idade"PlayerInfo[playerid][pIdade]);
    
PlayerInfo[playerid][pKills] = DOF2_GetInt(OnPlayerAccount(playerid), "Kills");
    
PlayerInfo[playerid][pDeaths] = DOF2_GetInt(OnPlayerAccount(playerid), "Deaths");
    
PlayerInfo[playerid][pLider] = DOF2_GetInt(OnPlayerAccount(playerid), "Lider");
    
PlayerInfo[playerid][pSubLider] = DOF2_GetInt(OnPlayerAccount(playerid), "SubLider");
    
PlayerInfo[playerid][pMembro] = DOF2_GetInt(OnPlayerAccount(playerid), "Membro");
    
PlayerInfo[playerid][pCargo] = DOF2_GetInt(OnPlayerAccount(playerid), "Cargo");
    
DOF2_GetInt(OnPlayerAccount(playerid), "Advertencias"PlayerInfo[playerid][pAdvertencias]);
    
DOF2_GetInt(OnPlayerAccount(playerid), "Calado"PlayerInfo[playerid][pCalado]);
    
DOF2_GetInt(OnPlayerAccount(playerid), "Preso"PlayerInfo[playerid][pPreso]);
    
SendClientMessage(playerid0xEAEF10AA"[SERVER] Dados Carregados com Sucesso!");
    
    
GivePlayerMoney(playeridGetCash(playerid));
    
OnPlayerLogin(playerid);
}
public 
TimeContas(playerid//Quando Player Loga й chamado este time para carregar os dados dele.
{
    
SetTimerEx("TimeContas2"200false"i"playerid);
}
public 
TimeContas2(playerid)
{
    
CarregarContas(playerid);
    return 
1;
}
//Funзхes de dinheiro ----------------------------------------------------------
forward GiveCash(playeridamount);
public 
GiveCash(playeridamount)
{
    
Cash[playerid] += amount;
    
ResetPlayerMoney(playerid);
    
GivePlayerMoney(playeridCash[playerid]);
    return 
1;
}
forward SetCash(playeridamount);
public 
SetCash(playeridamount)
{
    
Cash[playerid] = amount;
    
ResetPlayerMoney(playerid);
    
GivePlayerMoney(playeridCash[playerid]);
    return 
1;
}
forward  GetCash(playerid);
public 
GetCash(playerid)
{
    return 
Cash[playerid];
}
//------------------------------------------------------------------------------ 
Agore use somente as funзхes SetCash, GiveCash e GetCash para manipular o dinheiro dos jogadores.
Testei e tudo ams deu dois problemas, o primeiro й quando ele carrega os dados ele pega o valor original e dobra, se eu tinha 150 quando ele loga vai pra 300.

o Segundo erro й que ele nгo salva os valores novos, se durante o game eu adquiri mais 150, eu tinha 300 porque dobrou + 150 que ganhei no jogo, seriam 450, mas ele nгo salva e quando logo no banco de dados esta 150 mas o player esta com 300.

O que teve de errado no cуdigo?
Reply
#5

Vocк substitui todas as funзхes nativas pelas novas? A conta do usuбrio estб realmente sendo salva?
Reply
#6

Quote:
Originally Posted by RodrigoMSR
Посмотреть сообщение
Vocк substitui todas as funзхes nativas pelas novas? A conta do usuбrio estб realmente sendo salva?
Uhum fiz isso, e ele dobra o dinheiro do banco de dados quando loga e nгo salva o valor atual quando sai. :/
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)