Saveing text in a .cfg file
#1

hi i want to make a command so i can save text into a.cfg file so if i like type /setmessage it will save what i said in the .cfg or if i do /checkmessage it will tell me what i save.

i can script it my self but i just need some one to put me on the right track and tell me what i will need to do this.
Reply
#2

fopen
fwrite
fread
fclose
Reply
#3

so i have done and try to make a command for it and i got one error this is my command:
Code:
	if(strcmp(cmd, "/leaveanote", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
	    {
	        if(PlayerInfo[playerid][pAdmin] >= 1337)
			{
				tmp = strtok(cmdtext, idx);
				if(!strlen(tmp))
				{
					SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /leaveanote [Note(TEXT)]");
					return 1;
				}
				new note;
				note = strvalEx(tmp);
				{
					new File:log = fopen("/adminnotes.txt", io_write);
				    fwrite(log, note);// this is line 27006
    				fclose(log);
					format(string, sizeof(string), "   You have left the note %s", note);
					SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
				}
			}
		}
		return 1;
	}
and this is my error:
Code:
C:\Users\Ryan\Desktop\World Wide RolePlay\gamemodes\WWRP.pwn(27006) : error 035: argument type mismatch (argument 2)
Reply
#4

Maybe this will fix the error..

Code:
if(strcmp(cmd, "/leaveanote", true) == 0)
{
	if(IsPlayerConnected(playerid))
	{
        if(PlayerInfo[playerid][pAdmin] >= 1337)
		{
			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /leaveanote [Note(TEXT)]");
				return 1;
			}
			new note[255];
			note = strvalEx(tmp);
			new File:log = fopen("/adminnotes.txt", io_write);
			fwrite(log, note);// this is line 27006
			fclose(log);
			format(string, sizeof(string), "   You have left the note %s", note);
			SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
		}
	}
	return 1;
}
Reply
#5

Quote:
Originally Posted by Battleman
View Post
Maybe this will fix the error..

Code:
if(strcmp(cmd, "/leaveanote", true) == 0)
{
	if(IsPlayerConnected(playerid))
	{
        if(PlayerInfo[playerid][pAdmin] >= 1337)
		{
			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /leaveanote [Note(TEXT)]");
				return 1;
			}
			new note[255];
			note = strvalEx(tmp);
			new File:log = fopen("/adminnotes.txt", io_write);
			fwrite(log, note);// this is line 27006
			fclose(log);
			format(string, sizeof(string), "   You have left the note %s", note);
			SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
		}
	}
	return 1;
}
When i try what you did it gives me this error........

Code:
C:\Users\Ryan\Desktop\World Wide RolePlay\gamemodes\WWRP.pwn(27003) : error 033: array must be indexed (variable "note")
Reply
#6

Which line is the error one?
Reply
#7

Quote:
Originally Posted by sekol
View Post
Which line is the error one?
i have made a comment on the code where the error is

Look at my reply under where JamesC posted.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)