SA-MP Forums Archive
[Pedido] Salvar tudo oque os players digitarem - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: Non-English (https://sampforum.blast.hk/forumdisplay.php?fid=9)
+--- Forum: Languages (https://sampforum.blast.hk/forumdisplay.php?fid=33)
+---- Forum: Português/Portuguese (https://sampforum.blast.hk/forumdisplay.php?fid=34)
+---- Thread: [Pedido] Salvar tudo oque os players digitarem (/showthread.php?tid=568212)



Salvar tudo oque os players digitarem - _Play_ - 20.03.2015

Alguem pode me dizer alguma funзгo que faзa salvar num .txt tudo oque os players digitarem?


edit:

jб consegui usando um metodo parecido com o do Lуs


Re: Salvar tudo oque os players digitarem - #Luca[S]. - 20.03.2015

Salvar o que tem no Chat? Ou atй comandos em fim... ?


Re: Salvar tudo oque os players digitarem - _Play_ - 20.03.2015

tudo chat e comandos.


Re: Salvar tudo oque os players digitarem - #Luca[S]. - 20.03.2015

Bom, nгo testei direito mбs se der erros ou nгo funcionar me avise.
PHP код:
stock aNome(playerid)
{
    new 
NoMe[MAX_PLAYER_NAME];
    
GetPlayerName(playeridNoMesizeof(NoMe));
    return 
NoMe;
}
public 
OnPlayerText(playeridtext[])
{
new 
Tudo[128], Str2[128];
format(Tudosizeof(Tudo), "%s"text);
format(Str2sizeof(Str2), "%s: "aNome(playerid));
DOF2_SetString("TudoQueDigitarem.txt"Str2Tudo);
DOF2_SaveFile();
return 
1;
}
public 
OnPlayerCommandPerformed(playerid,cmdtext[],success)
{
    new 
Tudo[128], Str2[128];
    
format(Tudosizeof(Tudo), "%s"cmdtext);
    
format(Str2sizeof(Str2), "%s: "aNome(playerid));
    
DOF2_SetString("TudoQueDigitarem.txt"Str2Tudo);//Nao sei se da bug se salvar no msm local do outro
    
DOF2_SaveFile();
    return 
1;




Re: Salvar tudo oque os players digitarem - _Play_ - 20.03.2015

Quote:
Originally Posted by TenhoUmaDuvida
Посмотреть сообщение
Bom, nгo testei direito mбs se der erros ou nгo funcionar me avise.
PHP код:
stock aNome(playerid)
{
    new 
NoMe[MAX_PLAYER_NAME];
    
GetPlayerName(playeridNoMesizeof(NoMe));
    return 
NoMe;
}
public 
OnPlayerText(playeridtext[])
{
new 
Tudo[128], Str2[128];
format(Tudosizeof(Tudo), "%s"text);
format(Str2sizeof(Str2), "%s: "aNome(playerid));
DOF2_SetString("TudoQueDigitarem.txt"Str2Tudo);
DOF2_SaveFile();
return 
1;
}
public 
OnPlayerCommandPerformed(playerid,cmdtext[],success)
{
    new 
Tudo[128], Str2[128];
    
format(Tudosizeof(Tudo), "%s"cmdtext);
    
format(Str2sizeof(Str2), "%s: "aNome(playerid));
    
DOF2_SetString("TudoQueDigitarem.txt"Str2Tudo);//Nao sei se da bug se salvar no msm local do outro
    
DOF2_SaveFile();
    return 
1;

nгo salvou nada


Re: Salvar tudo oque os players digitarem - Lуs - 20.03.2015

Vocк pode tentar utilizando Losgs.


Re: Salvar tudo oque os players digitarem - Dayvison_ - 20.03.2015

Quote:
Originally Posted by TenhoUmaDuvida
Посмотреть сообщение
Estralho _Play_,

Acabei de testar e funcionou perfeitamente verifique se jб tem isso em sua GM:
PHP код:
public OnGameModeExit()
{
    
DOF2_Exit();
    return 
1;

E Tambйm crie o arquivo TudoQueDigitarem.txt dentro da pasta scriptfiles
Nao fera nao ira funcionar corretamente,
Faзa como Lуs disse ultiliza:
https://sampforum.blast.hk/showthread.php?tid=293534
ou fopen e fwrite

@edit aconselho os comandos na calback:
OnPlayerCommandText pois ela tambem mostrara os parametros


Re: Salvar tudo oque os players digitarem - #Luca[S]. - 20.03.2015

Quote:
Originally Posted by DayvisonJJB
Посмотреть сообщение
Nao fera nao ira funcionar corretamente,
Faзa como Lуs disse ultiliza:
https://sampforum.blast.hk/showthread.php?tid=293534
ou fopen e fwrite



Re: Salvar tudo oque os players digitarem - Dayvison_ - 20.03.2015

Quote:
Originally Posted by TenhoUmaDuvida
Посмотреть сообщение
Tem certeza que ao usar: DOF2_SetString sempre nesta key: "TenhoUmDuvida:" um valor nao substituira o outro?


Re: Salvar tudo oque os players digitarem - _Play_ - 20.03.2015

Consegui usando assim:

Код:
        //OnPlayerText
	format(string, sizeof(string), "%s: %s.", getPName(playerid), text);
	WriteLog("chat", string);

        //OnPlayerCommandPerformed
	format(string, sizeof(string), "%s: %s.", getPName(playerid), cmdtext);
	WriteLog("cmds", string);
//
stock WriteLog(filename[],text[])
{
	printf(text);
	new File:file;
	new filepath[256], string[128], year,day,month, hour,minute,second;
	getdate(year,day,month); gettime(hour,minute,second);
	format(filepath,sizeof(filepath),"FV/logs/%s.log",filename);
	file = fopen(filepath,io_append);
	format(string,sizeof(string),"[%02d/%02d/%d|%02d:%02d:%02d] %s\r\n",day,month,year,hour,minute,second,text);
	fwrite(file,string);
	fclose(file);
	return 1;
}