20.08.2012, 22:21
Preciso de ajuda nesse 2 cуdigos, estou iniciando na parte de criaзгo de files entгo deve ter um monte de merda, pois cada um desse 2 cуdigos sгo diferentes, mas os dois tem o mesmo problema, compilam normalmente mas tem AMX de 0 bytes e dгo crash ao iniciar servidor:
Cуdigo 1:
Cуdigo 2:
PS: Se alguйm souber a correзгo de qualquer um dos erros por favor me fala, pois nгo identifico o erro, o compilador compila normal e estou iniciando na parte de criaзгo de files .txt entгo pode ter erros que eu nгo saiba que existam, por favor ajudem '-'.
Cуdigo 1:
Код:
#include <a_samp> new plrIP[16]; new pname[MAX_PLAYER_NAME]; new string[128]; new Hour, Minute, Second; new Year, Month, Day; new File:abrirlog = fopen("ServerLog.txt",io_append); public OnFilterScriptInit() { print("\n--------------------------------------"); print(" Elog carregado"); print("--------------------------------------\n"); if(!fexist("ServerLog.txt")) { getdate(Year, Month, Day); gettime(Hour, Minute, Second); format(string, sizeof(string),"[%02d/%02d/%d][%02d:%02d:%02d] O servidor foi aberto..\r\n", Day, Month, Year, Hour, Minute, Second); fwrite(abrirlog, string); fclose(); } else { if(fhandle) { getdate(Year, Month, Day); gettime(Hour, Minute, Second); format(string, sizeof(string),"[%02d/%02d/%d][%02d:%02d:%02d] O servidor foi aberto..\r\n", Day, Month, Year, Hour, Minute, Second); fwrite(abrirlog, string); fclose(); } } } public OnFilterScriptExit() { if(!fexist("ServerLog.txt")) { getdate(Year, Month, Day); gettime(Hour, Minute, Second); format(string, sizeof(string),"[%02d/%02d/%d][%02d:%02d:%02d] O servidor foi fechado..\r\n", Day, Month, Year, Hour, Minute, Second); fwrite(abrirlog, string); fclose(); } else { if(fhandle) { getdate(Year, Month, Day); gettime(Hour, Minute, Second); format(string, sizeof(string),"[%02d/%02d/%d][%02d:%02d:%02d] O servidor foi fechado..\r\n", Day, Month, Year, Hour, Minute, Second); fwrite(abrirlog, string); fclose(); } } } public OnPlayerConnect(playerid) { if(!fexist("ServerLog.txt")) { getdate(Year, Month, Day); gettime(Hour, Minute, Second); GetPlayerName(playerid, pname, MAX_PLAYER_NAME); GetPlayerIp(playerid, plrIP, sizeof(plrIP)); format(string, sizeof(string),"[%02d/%02d/%d][%02d:%02d:%02d] %s [IP %d] entrou no servidor pelo ID:%s\r\n", Day, Month, Year, Hour, Minute, Second, pname, plrIP, playerid); fwrite(abrirlog, string); fclose(); } else { if(fhandle) { getdate(Year, Month, Day); gettime(Hour, Minute, Second); GetPlayerName(playerid, pname, MAX_PLAYER_NAME); GetPlayerIp(playerid, plrIP, sizeof(plrIP)); format(string, sizeof(string),"[%02d/%02d/%d][%02d:%02d:%02d] %s [IP %d] entrou no servidor pelo ID:%s\r\n", Day, Month, Year, Hour, Minute, Second, pname, plrIP, playerid); fwrite(abrirlog, string); fclose(); } } }
Код:
#include <a_samp> //Novo arquivo "Posicoes.txt" na Scriptfiles new File:Posicoes = fopen("Posicoes.txt", io_append); //Camera Mode new cameramode[20] = format(cameramode, sizeof(cameramode), "Camera Mode: %d\r\n", GetPlayerCameraMode(playerid)); //Camera Pos new Float:x, Float:y, Float:z; new camerapos[30] = format(camerapos, sizeof(camerapos), "Camera Pos: %f, %f, %f\r\n", GetPlayerCameraPos(playerid, x, y, z);); //Player Facing Angle new Float:Angle, PfacingAngle[26]; format(PfacingAngle, sizeof(PfacingAngle), "Player Facing Angle: %0.2f\r\n", GetPlayerFacingAngle(playerid, Angle);); //Player Interior new playerint[15] = format(playerint, sizeof(playerint), "Interior: %i\r\n",GetPlayerInterior(playerid)); //Player Pos new playerpos[30] = format(playerint, sizeof(playerint), "Pos: x,y,z\r\n",GetPlayerPos(playerid, x, y, z);); //Player Virtual World new virtualworld[32] = format(virtualworld, sizeof(virtualworld), "Virtual World: %d\r\n", GetPlayerVirtualWorld(playerid)); //Nome new nome[MAX_PLAYER_NAME+1], string[24+MAX_PLAYER_NAME+1] = format(nome, sizeof(nome), "Nome: %s\r\n -- \r\n \r\n", GetPlayerName(playerid, name, sizeof(name));); public OnFilterScriptInit() { print("\n--------------------------------------"); print(" E-Save carregado "); print("--------------------------------------\n"); return 1; } public OnFilterScriptExit() { return 1; } public OnPlayerCommandText(playerid, cmdtext[]) { if (strcmp("/salvarp", cmdtext, true, 10) == 0) { if(!fexist("Posicoes.txt")) { print("O arquivo Posicoes.txt foi criado!"); } else { new File:fhandle = fopen("Posicoes.txt",io_append); if(fhandle) { fwrite(fhandle, nome, playerpos, playerint, PfacingAngle, virtualworld, camerapos, cameramode,); fclose(fhandle); } } return 1; } return 0; }