public OnPlayerDeath(playerid, killerid, reason) { new arquivo[40], name[MAX_PLAYER_NAME]; //Salva as kills de quem matou if(killerid != INVALID_PLAYER_ID) { Player[killerid][Kills]++; //Adiciona uma kill na variбvel do jogador GetPlayerName(killerid, name, 32); format(arquivo, 40, "Contas/%s.ini", name); //Formata o nome do arquivo da conta do jogador if(DOF2_FileExists(arquivo)) { DOF2_SetInt(arquivo, "Kills", Player[killerid][Kills]); DOF2_SaveFile(); } } //Salva as deaths de quem morreu Player[playerid][Deaths]++; GetPlayerName(playerid, name, 32); format(arquivo, 40, "Contas/%s.ini", name); if(DOF2_FileExists(arquivo)) { DOF2_SetInt(arquivo, "Deaths", Player[playerid][Deaths]); DOF2_SaveFile(); } return 1; }
Nгo tenho muita experiкncia com DOF2, mas acho que seria algo assim:
Код:
public OnPlayerDeath(playerid, killerid, reason) { new arquivo[40], name[MAX_PLAYER_NAME]; //Salva as kills de quem matou if(killerid != INVALID_PLAYER_ID) { Player[killerid][Kills]++; //Adiciona uma kill na variбvel do jogador GetPlayerName(killerid, name, 32); format(arquivo, 40, "Contas/%s.ini", name); //Formata o nome do arquivo da conta do jogador if(DOF2_FileExists(arquivo)) { DOF2_SetInt(arquivo, "Kills", Player[killerid][Kills]); DOF2_SaveFile(); } } //Salva as deaths de quem morreu Player[playerid][Deaths]++; GetPlayerName(playerid, name, 32); format(arquivo, 40, "Contas/%s.ini", name); if(DOF2_FileExists(arquivo)) { DOF2_SetInt(arquivo, "Deaths", Player[playerid][Deaths]); DOF2_SaveFile(); } return 1; } |
public OnPlayerDeath(playerid, killerid, reason)
{
if(killerid != INVALID_PLAYER_ID)
{
Player[killerid][Kills]++;
new file[50];
format(file, sizeof(file), PASTA_CONTAS, PlayerName(playerid));
DOF2_SetInt(file, "Matou", Player[killerid][Kills]);
DOF2_SaveFile();
}
PlayerDeaths[playerid] ++;
new file[50];
format(file, sizeof(file), PASTA_CONTAS, PlayerName(playerid));
DOF2_SetInt(file, "Morreu", Player[playerid][Death]);
DOF2_SaveFile();
return 1;
}
error 017: undefined symbol "Player"
warning 215: expression has no effect
error 001: expected token: ";", but found "]"
error 029: invalid expression, assumed zero
fatal error 107: too many error messages on one line
enum DATA_P
{
P_KILL,
P_DEATH
};
new PLAYER_DATA[MAX_PLAYERS][DATA_P];
public OnPlayerDisconnect(playerid, reason)
{
SaveData(playerid);
return 1;
}
public OnPlayerSpawn(playerid)
{
LoadData(playerid);
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
if(killerid != INVALID_PLAYER_ID)
{
PLAYER_DATA[playerid][P_DEATH] ++;
PLAYER_DATA[killerid][P_KILL] ++;
}
return 1;
}
/* PARA SALVAR OS DADOS */
SaveData(playerid)
{
if(DOF2_FileExists(GetPlayerFileEx(playerid)))
{
DOF2_SetInt(GetPlayerFileEx(playerid), "KILL", PLAYER_DATA[playerid][P_KILL]);
DOF2_SetInt(GetPlayerFileEx(playerid), "DEATH", PLAYER_DATA[playerid][P_DEATH]);
DOF2_SaveFile();
}
else
{
DOF2_CreateFile(GetPlayerFileEx(playerid));
DOF2_SetInt(GetPlayerFileEx(playerid), "KILL", 0);
DOF2_SetInt(GetPlayerFileEx(playerid), "DEATH", 0);
DOF2_SaveFile();
}
return 1;
}
/* PARA CARREGAR OS DADOS */
LoadData(playerid)
{
if(DOF2_FileExists(GetPlayerFileEx(playerid)))
{
PLAYER_DATA[playerid][P_KILL] = DOF2_GetInt(GetPlayerFileEx(playerid), "KILL");
PLAYER_DATA[playerid][P_DEATH] = DOF2_GetInt(GetPlayerFileEx(playerid), "DEATH");
}
else
{
DOF2_CreateFile(GetPlayerFileEx(playerid));
DOF2_SetInt(GetPlayerFileEx(playerid), "KILL", 0);
DOF2_SetInt(GetPlayerFileEx(playerid), "DEATH", 0);
DOF2_SaveFile();
}
return 1;
}
/* PEGAR O ARQUIVO */
GetPlayerFileEx(playerid)
{
static p_file[40], p_name[MAX_PLAYER_NAME];
GetPlayerName(playerid, p_name, MAX_PLAYER_NAME);
format(p_file, 40, "diretorio/%s.ini", p_name);
return p_file;
}
Felipe eu montei assim:
PHP код:
PHP код:
|
new kills[MAX_PLAYERS], deaths[MAX_PLAYERS];
enum E_PLAYER { Kills, Deaths }; new Player[MAX_PLAYERS][E_PLAYER];
new PlayerInfo[MAX_PLAYERS][pInfo];
enum pInfo
{
pKills,
pDeaths
};
public OnPlayerDeath(playerid, killerid, reason)
{
if(killerid != INVALID_PLAYER_ID)
{
PlayerInfo[killerid][pKills]++;
}
PlayerInfo[playerid][pDeaths]++;
return 1;
}