help with this thing
#1

Okay, im trying to make a /suggest command where players can type for example: /suggest you should make some buyable houses

and it will leave a folder called Suggestions in my scriptfiles with that in it this is what i got
Код:
CMD:suggest(playerid,params[])
{
	new suggestion[256], str[256],name[MAX_PLAYER_NAME];
	if(sscanf(params,"s[256]",suggestion))
	{
 		SendClientMessage(playerid, 0xFF0000FF, "USAGE: /suggest [SUGGESTION]");
	    return 1;
	}
	GetPlayerName(playerid,name,sizeof(name));
	if(!dini_Exists("NewAdmin/Config/Suggestions.txt"))
	{
		dini_Create("NewAdmin/Config/Suggestions.txt");
  		format(str,sizeof(str),"%s: %s",name,suggestion);
	    dini_Set("NewAdmin/Config/Suggestions.txt","Suggestion:",str);
		
	}
	else
	{
	    format(str,sizeof(str),"%s: %s",name,suggestion);
	    dini_Set("NewAdmin/Config/Suggestions.txt","Suggestion:",str);
	    SendClientMessage(playerid,LIGHTBLUE,"Thanks for your suggestion, we will look into it...");
	}
	return 1;
}
I dont normaly set the strings to 256 its just that the file only saved half my message if i say "You should make some more enterable houses, that would be nice ", it would come out as

Suggestion: name=You should make some more enterable houses that

and also if i type another suggestion it overwrites the last suggestion how do i make it go onto a new line?
Reply
#2

dini is a bad choice here, so we use normal file functions

pawn Код:
CMD:suggest(playerid, params[])
{
    #define filename ("NewAdmin/Config/Suggestions.txt")
    if(sscanf(params,"{s[128]}")) { //just checks if the parameter is given
        return SendClientMessage(playerid, 0xFF0000FF, "USAGE: /suggest [SUGGESTION]");
    } //since we only have one parameter we can directly use "params"
    if(!dini_Exists(filename)) dini_Create(filename);
    new tmp[155]; //128 (max input) + 24 (MAX_PLAYER_NAME) + 4 (": " and "\r\n") = 156
    GetPlayerName(playerid, tmp, MAX_PLAYER_NAME);
    format(tmp, sizeof(tmp), "%s: %s\r\n", tmp, params);
    new File:gfile = fopen(filename, io_append);
    fwrite(gfile, tmp), fclose(gfile);
    return SendClientMessage(playerid, LIGHTBLUE,
        "Thanks for your suggestion, we will look into it...");
    #undef filename
}
Reply
#3

theres no compiling errors but nothing happens when i type /suggest blah blah in game, and if i type /suggest by itself i dont get a message saying USAGE: /suggest message and also i dont get the message at the end, "Thanks for your suggestion, we will look into it..."
??
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)