[Ajuda] DOF2
#1

alguem pode me ajudar com isso? eu tou tentando salvar a sede/fome do jogador mas eu nunca salvei algo em float, nao sei se tou colocando as linhas certas! alguem da uma olhadinha ai pra mim pfv?

Quote:

D:\samp037_svr_R2-1-1_win32\gamemodes\survive1.pwn(705) : warning 213: tag mismatch
D:\samp037_svr_R2-1-1_win32\gamemodes\survive1.pwn(705) : error 032: array index out of bounds (variable "Player")
D:\samp037_svr_R2-1-1_win32\gamemodes\survive1.pwn(722) : warning 213: tag mismatch
D:\samp037_svr_R2-1-1_win32\gamemodes\survive1.pwn(722) : error 032: array index out of bounds (variable "Player")
D:\samp037_svr_R2-1-1_win32\gamemodes\survive1.pwn(723) : warning 213: tag mismatch
D:\samp037_svr_R2-1-1_win32\gamemodes\survive1.pwn(723) : error 032: array index out of bounds (variable "Player")
D:\samp037_svr_R2-1-1_win32\gamemodes\survive1.pwn(723) : warning 213: tag mismatch
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase

Quote:

stock SavePlayer(playerid)
{
if( DOF2_FileExists( GetPlayerArquivo( playerid ) ) )
{

DOF2_CreateFile(GetPlayerArquivo(playerid));

//DOF2_SetInt( GetPlayerArquivo( playerid ), "Skin", Player[ playerid ][ Skin ] );
DOF2_SetInt( GetPlayerArquivo( playerid ), "Score", Player[ playerid ][ Score ] );
DOF2_SetInt( GetPlayerArquivo( playerid ), "Dinheiro", GetPlayerMoney( playerid ));
DOF2_SetInt( GetPlayerArquivo( playerid ), "Admin", Player[ playerid ][ Admin ] );
DOF2_SetInt( GetPlayerArquivo( playerid ), "AliveTime", Player[playerid][pDTime]);
DOF2_SetInt( GetPlayerArquivo( playerid ), "Sede", Player[playerid][pSede]);

DOF2_SaveFile();

}
return 1;
}

stock LoadPlayer(playerid)
{
if( DOF2_FileExists( GetPlayerArquivo( playerid ) ) )
{
//Player[ playerid ][ Skin ] = DOF2_GetInt( GetPlayerArquivo( playerid ), "Skin" );
Player[ playerid ][ Score ] = DOF2_GetInt( GetPlayerArquivo( playerid ), "Score" );
Player[ playerid ][ Dinheiro ] = DOF2_GetInt( GetPlayerArquivo( playerid ), "Dinheiro" );
Player[ playerid ][ Admin ] = DOF2_GetInt( GetPlayerArquivo( playerid ), "Admin" );
Player[ playerid ][ pDTime ] = DOF2_GetInt( GetPlayerArquivo(playerid), "Alive Time");
Player[ playerid ][ pSede ] = FloatOF2_GetFloat(GetPlayerArquivo(playerid),"Se de");
SetPlayerScore( playerid, Player[ playerid ][ Score ] );
//SetPlayerSkin(playerid, Player[ playerid ][ Skin ] );

}
return 1;
}

2. deem uma olhada no alive time tbm pfv, no arquivo apareque o tempo certo do alive time, mas quando entro no sv ele zera!
Reply
#2

Se vocк salva a sede como um nъmero inteiro, vocк estб pegando seu valor como se fosse Float, caso o nъmero que atribui o nнvel de sede do jogador for inteiro, mude para:
Код:
Player[ playerid ][ pSede ] = DOF2_GetInt(GetPlayerArquivo(playerid),"Sede");
Jб ao segundo erro, vocк estб colocando espaзos na string correspondente ao tempo vivo do jogador (tambйm acontece quando vocк carrega a sede do jogador, mas jб arrumei acima ).
Код:
DOF2_SetInt( GetPlayerArquivo( playerid ), "AliveTime", Player[playerid][pDTime]); //Vocк salva com "AliveTime"
Player[ playerid ][ pDTime ] = DOF2_GetInt( GetPlayerArquivo(playerid), "Alive Time"); //Mas tenta pegar seu valor com "Alive Time".
Percebe o erro? O correto seria:
Код:
Player[ playerid ][ pDTime ] = DOF2_GetInt( GetPlayerArquivo(playerid), "AliveTime");
------
A propуsito, vocк estб fazendo algo meio desnecessбrio no inнcio do cуdigo, criando outro arquivo (mesmo que este substitua o anterior) jб tendo um existente, irei lhe passar o algoritmo corrigido abaixo:
PHP код:
stock SavePlayer(playerid)
{
    if(!
DOF2_FileExistsGetPlayerArquivoplayerid ) ) )
        
DOF2_CreateFile(GetPlayerArquivo(playerid));
    
//DOF2_SetInt( GetPlayerArquivo( playerid ), "Skin", Player[ playerid ][ Skin ] );
    
DOF2_SetIntGetPlayerArquivoplayerid ), "Score"Playerplayerid ][ Score ] );
    
DOF2_SetIntGetPlayerArquivoplayerid ), "Dinheiro"GetPlayerMoneyplayerid ));
    
DOF2_SetIntGetPlayerArquivoplayerid ), "Admin"Playerplayerid ][ Admin ] );
    
DOF2_SetIntGetPlayerArquivoplayerid ), "AliveTime"Player[playerid][pDTime]);
    
DOF2_SetIntGetPlayerArquivoplayerid ), "Sede"Player[playerid][pSede]);
    
DOF2_SaveFile();
    return 
1;

Sу serб preciso criar um novo arquivo caso nгo existir um, nй?
Sу mais uma coisa, se vocк estб usando estas funзхes, nгo precisa colocar "stock" em seu nome
Reply
#3

pawn Код:
DOF2_SetFloat(file[],key[],Float:value);  //funзгo para Salvar Em Float

DOF2_GetFloat(file[], key[]); //Funзгo para pegar(getar) uma variavel Float
Reply
#4

Quote:
Originally Posted by Manorango
Посмотреть сообщение
Se vocк salva a sede como um nъmero inteiro, vocк estб pegando seu valor como se fosse Float, caso o nъmero que atribui o nнvel de sede do jogador for inteiro, mude para:
Код:
Player[ playerid ][ pSede ] = DOF2_GetInt(GetPlayerArquivo(playerid),"Sede");
Jб ao segundo erro, vocк estб colocando espaзos na string correspondente ao tempo vivo do jogador (tambйm acontece quando vocк carrega a sede do jogador, mas jб arrumei acima ).
Код:
DOF2_SetInt( GetPlayerArquivo( playerid ), "AliveTime", Player[playerid][pDTime]); //Vocк salva com "AliveTime"
Player[ playerid ][ pDTime ] = DOF2_GetInt( GetPlayerArquivo(playerid), "Alive Time"); //Mas tenta pegar seu valor com "Alive Time".
Percebe o erro? O correto seria:
Код:
Player[ playerid ][ pDTime ] = DOF2_GetInt( GetPlayerArquivo(playerid), "AliveTime");
------
A propуsito, vocк estб fazendo algo meio desnecessбrio no inнcio do cуdigo, criando outro arquivo (mesmo que este substitua o anterior) jб tendo um existente, irei lhe passar o algoritmo corrigido abaixo:
PHP код:
stock SavePlayer(playerid)
{
    if(!
DOF2_FileExistsGetPlayerArquivoplayerid ) ) )
        
DOF2_CreateFile(GetPlayerArquivo(playerid));
    
//DOF2_SetInt( GetPlayerArquivo( playerid ), "Skin", Player[ playerid ][ Skin ] );
    
DOF2_SetIntGetPlayerArquivoplayerid ), "Score"Playerplayerid ][ Score ] );
    
DOF2_SetIntGetPlayerArquivoplayerid ), "Dinheiro"GetPlayerMoneyplayerid ));
    
DOF2_SetIntGetPlayerArquivoplayerid ), "Admin"Playerplayerid ][ Admin ] );
    
DOF2_SetIntGetPlayerArquivoplayerid ), "AliveTime"Player[playerid][pDTime]);
    
DOF2_SetIntGetPlayerArquivoplayerid ), "Sede"Player[playerid][pSede]);
    
DOF2_SaveFile();
    return 
1;

Sу serб preciso criar um novo arquivo caso nгo existir um, nй?
Sу mais uma coisa, se vocк estб usando estas funзхes, nгo precisa colocar "stock" em seu nome
%.0i e oque?

format(str, sizeof(str), "%.0i%", pInfo[playerid][pSede]);
PlayerTextDrawSetString(playerid, PLAYER_HUD[playerid][13], str);
Reply
#5

Nгo lembro ao certo o que isto faz, mas seu uso teoricamente й para formatar os algarismos de um nъmero de tal modo. Exemplo:
PHP код:
main() {
    new 
str[40], val 1;
    
format(strsizeof(str), "%03d"val); //format(str, sizeof(str), "%03i", val) й a mesma coisa, o especificador "d" e "i" equivalem a um numero inteiro
    
printf("%s"str);

Isto irб imprimir "001" na tela
Reply
#6

fiz assim:

Quote:

stock SavePlayer(playerid)
{
if(!DOF2_FileExists( GetPlayerArquivo( playerid ) ) )
DOF2_CreateFile(GetPlayerArquivo(playerid));

//DOF2_SetInt( GetPlayerArquivo( playerid ), "Skin", Player[ playerid ][ Skin ] );
DOF2_SetInt( GetPlayerArquivo( playerid ), "Score", Player[ playerid ][ Score ] );
DOF2_SetInt( GetPlayerArquivo( playerid ), "Dinheiro", GetPlayerMoney( playerid ));
DOF2_SetInt( GetPlayerArquivo( playerid ), "Admin", Player[ playerid ][ Admin ] );
DOF2_SetInt( GetPlayerArquivo( playerid ), "AliveTime", Player[playerid][pDTime]);
DOF2_SetInt( GetPlayerArquivo( playerid ), "pSexo", Player[playerid][pSexo]);
DOF2_SetInt( GetPlayerArquivo( playerid ),"pSede", pInfo[playerid][pSede]);

DOF2_SaveFile();
return 1;
}

stock LoadPlayer(playerid)
{
if( DOF2_FileExists( GetPlayerArquivo( playerid ) ) )
{
//Player[ playerid ][ Skin ] = DOF2_GetInt( GetPlayerArquivo( playerid ), "Skin" );
Player[ playerid ][ Score ] = DOF2_GetInt( GetPlayerArquivo( playerid ), "Score" );
Player[ playerid ][ Dinheiro ] = DOF2_GetInt( GetPlayerArquivo( playerid ), "Dinheiro" );
Player[ playerid ][ Admin ] = DOF2_GetInt( GetPlayerArquivo( playerid ), "Admin" );
Player[ playerid ][ pDTime ] = DOF2_GetInt( GetPlayerArquivo(playerid), "AliveTime");
Player[ playerid ][ pSexo ] = DOF2_GetInt( GetPlayerArquivo(playerid), "pSexo");
Player[ playerid ][ pSede ] = DOF2_GetInt( GetPlayerArquivo(playerid),"pSede");

SetPlayerScore( playerid, Player[ playerid ][ Score ] );
GivePlayerMoney( playerid, Player[ playerid] [ Dinheiro ] );
//SetPlayerSkin(playerid, Player[ playerid ][ Skin ] );

}
return 1;
}

mas da esse warn:
Quote:

D:\samp037_svr_R2-1-1_win32\gamemodes\survive1.pwn(835) : warning 213: tag mismatch
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


1 Warning.

Reply
#7

Algum destes dados nгo й do tipo inteiro.
O que hб nas linhas 835 e 836? Provavelmente algum dado dai й do tipo Float mas nгo estou sabendo qual possa ser.
Reply
#8

a linha q ta dando warning e essa:

Quote:

Player[ playerid ][ pSede ] = DOF2_GetInt( GetPlayerArquivo(playerid),"pSede");

esse e o sistema que eu uso:
Quote:

enum Player_Data
{
bool: pConectado,
pIdioma,
pAdmin,
pAviso,
bool: pMute,
bool: pBlockPM,
pChat,
pBackpack,
pSlots,
pFome,
pSede,
pRadiation,
pReputation,
pExp,
pLevel,
pRespawn,
pSangrando,
pQuebrado,
pTemGPS,
pTemColete,
pTemCapacete
};

new pInfo[MAX_PLAYERS][Player_Data];

Quote:

public OnPlayerUpdate(playerid)
{
if(!IsPlayerNPC(playerid) && IsPlayerConnected(playerid))
{
if(pInfo[playerid][pConectado] == true)
{
new str[200];

format(str, sizeof(str), "[~y~%s~w~]", PegarNome(playerid));
PlayerTextDrawSetString(playerid, PLAYER_HUD[playerid][22], str);

format(str, sizeof(str), "%.0i%", pInfo[playerid][pFome]);
PlayerTextDrawSetString(playerid, PLAYER_HUD[playerid][9], str);

format(str, sizeof(str), "%.0i%", pInfo[playerid][pSede]);
PlayerTextDrawSetString(playerid, PLAYER_HUD[playerid][13], str);


if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
new vehicleid = GetPlayerVehicleID(playerid);
format(str, sizeof(str), "Fuel: ~r~%i~n~~w~Engine: %s", vInfo[vehicleid][vCombustivel], vInfo[vehicleid][vTemMotor] ? ("~g~Yes") : ("~r~None"));
PlayerTextDrawSetString(playerid, VEH_HUD[playerid][3], str);
}
}
}
return 1;
}

Quote:
public AtualizarSede()
{
foreach(Player, i)
{
if(pInfo[i][pConectado] == true && IsPlayerConnected(i) && !IsPlayerNPC(i))
{
if(pInfo[i][pSede] > 0) pInfo[i][pSede]--;
if(pInfo[i][pSede] == 5) SendClientMessage(i, COR_AMARELO, Translate(pInfo[i][pIdioma], "[Sede]: Voce esta ficando com Sede, beba alguma coisa ou comecara a perder vida.",
"[THIRST]: You're getting thirsty, drink something or will begin to lose health."));
if(pInfo[i][pSede] == 0)
{
new Float:health;
GetPlayerHealth(i, health), SetPlayerHealth(i, health-10);
SetPlayerDrunkLevel(i, 4500);
}
}
}
return 1;
}

Quote:

stock ResetarPlayer(playerid)
{
ResetPlayerInventory(playerid);
ResetPlayerWeapons(playerid);

if(pInfo[playerid][pSangrando] == 1) KillTimer(SangueTimer[playerid]);

pInfo[playerid][pChat] = 0;
pInfo[playerid][pQuebrado] = 0;
pInfo[playerid][pSangrando] = 0;
pInfo[playerid][pBackpack] = 5;
pInfo[playerid][pFome] = 80;
pInfo[playerid][pSede] = 80;
pInfo[playerid][pRadiation] = 0;

AddItem(playerid, "Water Canteen", 1);
AddItem(playerid, "Bandage", 1);
return 1;
}

Reply
#9

Aparentemente nгo hб nada fora do comum, mas tem certeza de que a array correspondente ao enumerador й "Player" ao invйs de "pInfo"? O correto nгo seria "pInfo[playerid][pSede] = DOF2_GetInt(...)"?
Reply
#10

agora foi, muito obrigado! so mais uma coisa, e os items do inventario? oque devo fazer pra salva-los?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)