How to create comment box and save?
#1

Hello guys,
i wanna to create a comment box in my server
i just created this input dialog
Код:
if(!strcmp(cmdtext, "/cbox", true))
	{
	    ShowPlayerDialog(playerid,30, DIALOG_STYLE_INPUT, "Server Comment Box", "Type your comment here.", "Submit", "Cancel");
	    return 1;
	}
and now i want the submited comment to save in file
Scrptfiles/Comments/%s.txt
anyone to help pls help me!!
Reply
#2

anyone help?
Reply
#3

I was about to help you, but you decide to double post after 5 minutes? Learn to be patient, we aren't slaves to help you at request.
Reply
#4

i am sory but i need help@
Reply
#5

simply make log like ban/kick
Reply
#6

Quote:
Originally Posted by Abreezy
Посмотреть сообщение
I was about to help you, but you decide to double post after 5 minutes? Learn to be patient, we aren't slaves to help you at request.
+1

Quote:
Originally Posted by dreamworld
Посмотреть сообщение
simply make log like ban/kick
DO you even know pawn code?


pawn Код:
CMD:c(file[], input[])
{
    File:filevar;
    if(!fexist(file)) filevar = fopen(file, io_write);
    else filevar = fopen(file, io_append);
    if(!fexist(file))
    {
        printf("Failed to load '%s'", file);
        return 0;
    }
    else
    {
        new str[512];
        format(str, sizeof(str), "%s\r\n", input);
        fwrite(filevar, input);
        fclos(filevar);
      return 1;
    }
}
Untested - I dont know basic SAMP file input text to file saving so this is a first


If this doesnt work wait for somone to edit it or i can make it for you in Y_INI
Reply
#7

Quote:
Originally Posted by IceCube!
Посмотреть сообщение
+1



DO you even know pawn code?


pawn Код:
CMD:c(file[], input[])
{
    File:filevar;
    if(!fexist(file)) filevar = fopen(file, io_write);
    else filevar = fopen(file, io_append);
    if(!fexist(file))
    {
        printf("Failed to load '%s'", file);
        return 0;
    }
    else
    {
        new str[512];
        format(str, sizeof(str), "%s\r\n", input);
        fwrite(filevar, input);
        fclos(filevar);
      return 1;
    }
}
Untested - I dont know basic SAMP file input text to file saving so this is a first


If this doesnt work wait for somone to edit it or i can make it for you in Y_INI
Since he wants to do it with a dialog, it's actually easier to make under ondialogresponse, since it has the "inputtext" option.
Reply
#8

Код:
forward TestLog(string[]);
Код:
#define TESTTEST 1
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
	if (strcmp("/testt", cmdtext, true, 10) == 0)
	{
		ShowPlayerDialog(playerid,TESTTEST, DIALOG_STYLE_INPUT, "Server Comment Box", "Type your comment here.", "Submit", "Cancel");
		return 1;
	}
	return 0;
}
Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
	if(dialogid == TESTTEST)
	{
		if(response)
		{
		        new string[120];
		        new sendername[MAX_PLAYER_NAME];
		        GetPlayerName(playerid, sendername, sizeof(sendername));
				strval(inputtext);
			    format(string, sizeof(string), "Message sent %s %s",sendername, inputtext);
			    SendClientMessageToAll(COLOR_WHITE, string);
				TestLog(string);
				return 1;
		}
	}
	return 1;
}
Код:
public TestLog(string[])
{
	new entry[200];
	format(entry, sizeof(entry), "%s\r\n",string);
	new File:hFile;
	hFile = fopen("testt.log", io_append);
	fwrite(hFile, entry);
	fclose(hFile);
}
Tested work
Reply
#9

Quote:
Originally Posted by Abreezy
Посмотреть сообщение
I was about to help you, but you decide to double post after 5 minutes? Learn to be patient, we aren't slaves to help you at request.
Quote:
Originally Posted by Abreezy
Посмотреть сообщение
Since he wants to do it with a dialog, it's actually easier to make under ondialogresponse, since it has the "inputtext" option.
Sorry I didnt read that he wanted it in dialog, Ill try to read it over again next time
Reply
#10

Quote:
Originally Posted by IceCube!
Посмотреть сообщение
Sorry I didnt read that he wanted it in dialog, Ill try to read it over again next time
No problem bro, at least you showed him another way for him to learn. Even tho i doubt most people read the help
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)