[Pedido] Salvar tudo oque os players digitarem
#1

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
Reply
#2

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

tudo chat e comandos.
Reply
#4

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;

Reply
#5

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
Reply
#6

Vocк pode tentar utilizando Losgs.
Reply
#7

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
Reply
#8

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
Reply
#9

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

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;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)