SA-MP Forums Archive
How to create comment box and save? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: How to create comment box and save? (/showthread.php?tid=279751)



How to create comment box and save? - HotPlayer - 28.08.2011

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!!


Re: How to create comment box and save? - HotPlayer - 28.08.2011

anyone help?


Re: How to create comment box and save? - Abreezy - 28.08.2011

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.


Re: How to create comment box and save? - HotPlayer - 28.08.2011

i am sory but i need help@


Re: How to create comment box and save? - dreamworld - 28.08.2011

simply make log like ban/kick


Re: How to create comment box and save? - IceCube! - 28.08.2011

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


Re: How to create comment box and save? - Abreezy - 28.08.2011

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.


Re: How to create comment box and save? - dreamworld - 28.08.2011

Код:
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


Re: How to create comment box and save? - IceCube! - 28.08.2011

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


Re: How to create comment box and save? - Abreezy - 28.08.2011

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