File help
#1

Hai!

Код:
		if(strcmp(cmdtext, "/suggest", true, 5)==0)
		{
		  new string[128], name[MAX_PLAYER_NAME];
		  new File:pos = fopen("suggestions.txt", io_append);
		  GetPlayerName(playerid, name, sizeof(name));
               if(!strlen(cmdtext)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /suggest <your suggestion>");
		  format(string, sizeof(string), "%s has suggested: %s ", name, cmdtext[6]);
		  fwrite(pos, string);
		  fwrite(pos, "\r\n");
		  fclose(pos);
		  SendClientMessage(playerid,COLOR_WHITE,"SERVER: You have done a suggestion!");
		  return 1;
		}
How come if you do /suggest ingame it says you have suggested something? I want it to be like: Usage: /suggesrt <yoursuggestion>.

Thanks in advance!
Reply
#2

You can do it in bigstrtok as well..
Reply
#3

Sorry could you explain that please?
Reply
#4

change
pawn Код:
if(!strlen(cmdtext)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /suggest <your suggestion>");
to
pawn Код:
if(strlen(cmdtext) < 10) return SendClientMessage(playerid, COLOR_RED, "USAGE: /suggest <your suggestion>");
Reply
#5

Quote:
Originally Posted by lrZ^
change
pawn Код:
if(!strlen(cmdtext)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /suggest <your suggestion>");
to
pawn Код:
if(strlen(cmdtext) < 10) return SendClientMessage(playerid, COLOR_RED, "USAGE: /suggest <your suggestion>");
then he still use the wrong cell ... so

you used the wrong length
pawn Код:
if(!strcmp(cmdtext, "/suggest", true, 8)) //"/suggest" is 8 character long
        {
            if(cmdtext[8] != 32 || cmdtext[9] == EOS)
                return SendClientMessage(playerid, COLOR_RED, "USAGE: /suggest <your suggestion>");
            SendClientMessage(playerid, COLOR_WHITE, "SERVER: You have done a suggestion!");
            //I send the message before so the player dont notices if lag arise within the code
            new string[128];
                File:pos = fopen("suggestions.txt", io_append);
            GetPlayerName(playerid, string, MAX_NAME_LENGTH); //you can use one array for that too because the array gets
            format(string, sizeof string, "%s has suggested: %s\r\n", string, cmdtext[9]); //after the function "format" overwriten
            fwrite(pos, string), fclose(pos);
            return true;
        }
Reply
#6

EOS and 32? :P
Explain pls
Reply
#7

Quote:
Originally Posted by lrZ^
EOS and 32? :P
Explain pls
32 is ' ' (space)
EOS means End of String, should be something like 0 I think
EOF = End of File
Reply
#8

Thanks but is has a few errors

C:\Users\Matthias\Desktop\SA-MP Stuff\Servers\Los Santos TDM - Without IRC\gamemodes\kkkk.pwn(317) : warning 221: label name "File" shadows tag name
C:\Users\Matthias\Desktop\SA-MP Stuff\Servers\Los Santos TDM - Without IRC\gamemodes\kkkk.pwn(317) : error 017: undefined symbol "pos"
C:\Users\Matthias\Desktop\SA-MP Stuff\Servers\Los Santos TDM - Without IRC\gamemodes\kkkk.pwn(31 : error 017: undefined symbol "MAX_NAME_LENGTH"
C:\Users\Matthias\Desktop\SA-MP Stuff\Servers\Los Santos TDM - Without IRC\gamemodes\kkkk.pwn(320) : error 017: undefined symbol "pos"
C:\Users\Matthias\Desktop\SA-MP Stuff\Servers\Los Santos TDM - Without IRC\gamemodes\kkkk.pwn(317) : warning 203: symbol is never used: "File"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


3 Errors.
Reply
#9

pawn Код:
if(!strcmp(cmdtext, "/suggest", true, 8)) //"/suggest" is 8 character long
        {
            if(cmdtext[8] != 32 || cmdtext[9] == EOS)
                return SendClientMessage(playerid, COLOR_RED, "USAGE: /suggest <your suggestion>");
            SendClientMessage(playerid, COLOR_WHITE, "SERVER: You have done a suggestion!");
            //I send the message before so the player dont notices if lag arise within the code
            new string[128], //                        Here's the fix, there was a ; instead of ,
                File:pos = fopen("suggestions.txt", io_append);
            GetPlayerName(playerid, string, MAX_NAME_LENGTH); //you can use one array for that too because the array gets
            format(string, sizeof string, "%s has suggested: %s\r\n", string, cmdtext[9]); //after the function "format" overwriten
            fwrite(pos, string), fclose(pos);
            return true;
        }
Reply
#10

Thanks, now there's only one error left:

C:\Users\Matthias\Desktop\SA-MP Stuff\Servers\Los Santos TDM - Without IRC\gamemodes\kkkk.pwn(326) : error 017: undefined symbol "MAX_NAME_LENGTH"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


1 Error.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)