Save what player has typed
#1

For example,I have some quetions,at a DMV test.
The player types an answer to a question,I want that question(what he wrote) to be saved in a variable so that what he typed can be sent to other players.

Thanks for your help.
Reply
#2

I don't fully understand your problem/help request. What i think you said is, you want to see what a player types?
Reply
#3

Quote:
Originally Posted by Abreezy
Посмотреть сообщение
I don't fully understand your problem/help request. What i think you said is, you want to see what a player types?
What don't you understand ? He's asking how to save what players typed as their answer and whatever they typed get saved to a notepad file (or some other editable text file).

Add this to the bottom of the script:

pawn Код:
forward SaveToFile(filename[],text[]);
public SaveToFile(filename[],text[])
{
    #if defined SAVE_LOGS
    new File:file, filepath[256], string[256], year,month,day, hour,minute,second;
    getdate(year,month,day); gettime(hour,minute,second);

    format(filepath,sizeof(filepath),"foldername/logs/%s.txt",filename);
    file = fopen(filepath,io_append);
    format(string,sizeof(string),"[%d.%d.%d %d:%d:%d] %s\r\n",day,month,year,hour,minute,second,text);
    fwrite(file,string);
    fclose(file);
    #endif

    return 1;
}
Change:

pawn Код:
foldername/logs/
to where you want your logs/typed log to save to. You must create the custom file in scriptfiles, so it should be something like ...

ServerDirectory/scriptfiles/TypedLog.txt

When the notepad file (TypedLog) is created, the script will find this file when we use our custom SaveToFile function.

Under where the player types the questions, use SaveToFile("TypedLog",string); assuming string is what is being used to format your text when they type and TypedLog as the name of your notepad file.
Reply
#4

Quote:
Originally Posted by grand.Theft.Otto
Посмотреть сообщение
What don't you understand ? He's asking how to save what players typed as their answer and whatever they typed get saved to a notepad file (or some other editable text file).

Add this to the bottom of the script:

pawn Код:
forward SaveToFile(filename[],text[]);
public SaveToFile(filename[],text[])
{
    #if defined SAVE_LOGS
    new File:file, filepath[256], string[256], year,month,day, hour,minute,second;
    getdate(year,month,day); gettime(hour,minute,second);

    format(filepath,sizeof(filepath),"foldername/logs/%s.txt",filename);
    file = fopen(filepath,io_append);
    format(string,sizeof(string),"[%d.%d.%d %d:%d:%d] %s\r\n",day,month,year,hour,minute,second,text);
    fwrite(file,string);
    fclose(file);
    #endif

    return 1;
}
Change:

pawn Код:
foldername/logs/
to where you want your logs/typed log to save to. You must create the custom file in scriptfiles, so it should be something like ...

ServerDirectory/scriptfiles/TypedLog.txt

When the notepad file (TypedLog) is created, the script will find this file when we use our custom SaveToFile function.

Under where the player types the questions, use SaveToFile("TypedLog",string); assuming string is what is being used to format your text when they type and TypedLog as the name of your notepad file.
A bit not necessary, because server saves what player typed by itself (log file).
I think, that he mean, that a var saves what player typed.

Somethink like this?
pawn Код:
new WhatIveWrote[255];
OnPlayerText(playerid, text[])
{
         WhatIveWrote = strval(text);
         return 1;
}
Or somethink else.. Dunn0
Reply
#5

Ah ye true, the original one I had was to write to the file what commands players typed and not what they typed in the chat, except this one I changed a bit so it tells you what they typed.
Reply
#6

Quote:
Originally Posted by LetsOWN[PL]
Посмотреть сообщение
A bit not necessary, because server saves what player typed by itself (log file).
I think, that he mean, that a var saves what player typed.
Well, This is not completly true in my opinion.. It mostly depends on which input methode, the scripter is using to complete the DMV test. If it would be inside OnPlayerText, then yes it would be saved automaticly in server_log.log file. If the input methode is Dialog's, then it wouldn't be saved in the server_log file. And saving the answers of any tests in just 1 certain log file would be the best option in my opinion. Because it would take longer to search in the server_log file instead of making just 1 certain log file.

Just wanted to share my opinion about this.

Kind Regards,
Improvement™
Reply
#7

LetsOwn understood my question. So yes,basically that's what I need,to save that thing in a variable.
I am using a GF edit,the FCRP one,so I need to save what he typed.
For example, if he typed at Answer1 - I don't know this question
A variable,instead of saving a number ( ex: 263) saves what he typed ( I don't know this question ). That's what I need.

Note: I don't use OnPlayerText,I use a command /answer1,so after he types /answer1 I don't know this question,his answer ( I don't know this question ) will be saved to a variable. I did the command but IDK how to make a variable that saves text instead of numbers. That's my problem
Reply
#8

i suggest the PVars:
Код:
SetPVarString(playerid,"Answered",params);
idk if you use params in your command, maybe its cmdtext.
to send a message to all (other) players will require a loop:
Код:
new string[128];
new answer[128];
GetPVarString(playerid,"Answered",answer,128)
new Name[MAX_PLAYER_NAME];
GetPlayerName(playerid,Name,sizeof(Name));
format(string,sizeof(string),"(%d)%s answered: %s",playerid,Name,answer);
for(new id=0;id<MAX_PLAYERS;id++)
{
if(playerid!=id)
{
SendClientMessage(id,0xffffffff,string);
}
}
only the concept, didnt add the IsPlayerConnected etc stuff...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)