SA-MP Forums Archive
File help - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: File help (/showthread.php?tid=69648)



File help - GTA_Rules - 19.03.2009

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!


Re: File help - MenaceX^ - 19.03.2009

You can do it in bigstrtok as well..



Re: File help - GTA_Rules - 19.03.2009

Sorry could you explain that please?


Re: File help - LarzI - 19.03.2009

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>");



Re: File help - Nero_3D - 19.03.2009

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;
        }



Re: File help - LarzI - 19.03.2009

EOS and 32? :P
Explain pls


Re: File help - Nero_3D - 19.03.2009

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


Re: File help - GTA_Rules - 19.03.2009

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.


Re: File help - LarzI - 19.03.2009

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;
        }



Re: File help - GTA_Rules - 19.03.2009

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.