08.12.2013, 22:44
Basta modificar a include.
Gamemode:
Sу adaptar.
pawn Код:
////////////////////////////////////////////////////////////////////////////////
//
//
// #### ######## ###### ######## ######## ### ## ##
// ## ## ## ## ## ## ## ## ## ### ###
// ## ## ## ## ## ## ## ## #### ####
// ## ######## ###### ## ###### ## ## ## ### ##
// ## ## ## ## ## ######### ## ##
// ## ## ## ## ## ## ## ## ## ##
// #### ## ###### ## ######## ## ## ## ##
//
//
// DelAuto Acc v2.0
//
/* ______ ______ _
// | ___ \ | ___ \ | |
// | |_/ /_ _ | |_/ /_ _ _ _| | ___
// | ___ \ | | | | __/ _` | | | | |/ _ \
// | |_/ / |_| |_ | | | (_| | |_| | | (_) |
// \____/ \__, (_) \_| \__,_|\__,_|_|\___/
// __/ |
// |___/
*/
//
// !!! Deleta automaticamente contas de usuбrios inativos, usando INI !!!
//
// [iPs]TeaM soluзхes de programaзгo em geral (agora com cursos)
//
// http://ips-team.forumeiros.com/ (contate-nos)
//
/////////////////////////////////////////////////////////////////////////////////
#define pTIME 30 //Coloque em dias aqui o tempo para que a Acc seja deletada.
#define pFILE "Contas/%s.ini" //Coloque aqui o caminho das contas dos Players.
#define pBACKUP "pBackup" //Configure aqui sua Pasta de Backups.
#define pCriarArq(%0) fclose(fopen(%0, io_append))
#define pUSERS 255 //Nъmero de linhas mбximo das Acc's.
#if !defined isnull
#define isnull(%1) !(%1[0]) || %1[0] == '\1' && !(%1[1])
#endif
forward OnAccountDeleted(conta[]);
public OnGameModeInit() {
if(fexist("pNameUsers.Paulo")) {
new File: pArq, pTime = gettime(), pStr[64], pName[24], pFind;
pArq = fopen("pNameUsers.Paulo", io_read);
while(fread(pArq, pStr)) {
if(pTime > strval(pStr[(pFind = strfind(pStr, "=") + 1)]) > 0) {
strmid(pName, pStr, 0, (pFind - 1));
format(pStr, 64, pFILE, pName);
pRemoveKey("pNameUsers.Paulo", pName);
printf("User: %s teve sua Conta deletada pois ficou invativo por mais de %i dias.", pName, pTIME);
pMoveFile(pStr);
CallLocalFunction("OnAccountDeleted", "s", pName);
}
}
fclose(pArq);
} else pCriarArq("pNameUsers.Paulo");
return CallLocalFunction("DelOnGameModeInit", #);
}
public OnPlayerConnect(playerid) {
if(fexist("pNameUsers.Paulo")) pWriteFile("pNameUsers.Paulo", pGetPlayerName(playerid), (gettime() + (60 * 60 * 24 * pTIME)));
return CallLocalFunction("DelOnPlayerConnect", "i", playerid);
}
#if defined _ALS_OnGameModeInit
#undef OnGameModeInit
#else
#define _ALS_OnGameModeInit
#endif
#if defined _ALS_OnPlayerConnect
#undef OnPlayerConnect
#else
#define _ALS_OnPlayerConnect
#endif
#define OnGameModeInit DelOnGameModeInit
#define OnPlayerConnect DelOnPlayerConnect
forward DelOnGameModeInit();
forward DelOnPlayerConnect(playerid);
pGetPlayerName(playerid) {
new pName[24];
GetPlayerName(playerid, pName, 24);
return pName;
}
pWriteFile(file[], key[], valor) {
new File: pArq, pStr[40];
pRemoveKey(file, key);
pArq = fopen(file, io_append);
format(pStr, 40, "%s=%i\r\n", key, valor);
fwrite(pArq, pStr);
fclose(pArq);
return 1;
}
stock pFileSave[pUSERS][128], bFileSave[pUSERS][128];
pMoveFile(file[]) {
new File: pFile, pStr[35], pPos;
if(!fexist(file)) return 0;
pFileSave = bFileSave;
pFile = fopen(file, io_read);
while(fread(pFile, pStr)) pFileSave[pPos++] = pStr;
fclose(pFile);
fremove(file);
strdel(file, 0, strfind(file, "/"));
format(file, 64, "%s/%s", pBACKUP, file);
pFile = fopen(file, io_write);
for(new pI; pPos > -1; --pPos) fwrite(pFile, pFileSave[pI++]);
fclose(pFile);
return 1;
}
pRemoveKey(file[], ignorekey[]) {
new File: pFile, pStr[35], bool: pVar, pPos;
if(!fexist(file)) return 0;
pFileSave = bFileSave;
pFile = fopen(file, io_read);
while(fread(pFile, pStr)) {
if(strfind(pStr, ignorekey, true) == -1) {
pFileSave[pPos++] = pStr;
} else pVar = true;
}
fclose(pFile);
if(!pVar) return 0;
fremove(file);
pFile = fopen(file, io_write);
for(new pI; pPos > -1; --pPos) fwrite(pFile, pFileSave[pI++]);
fclose(pFile);
return 1;
}
Gamemode:
pawn Код:
public OnAccountDeleted(conta[]) {
new i;
for ( i = 0; i < MAX_EMPRESAS; ++i ) {
if (!strcmp(BizzInfo[i][bOwner], conta) ) {
// ... Vender
}
}
return true;
}