[HELP]Syntax Error.
#1

I have been getting this error -
pawn Код:
\gamemodes\mortals.pwn(17479) : error 076: syntax error in the expression, or invalid function call
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


1 Error.
And the line is -
pawn Код:
format(string,sizeof(string),"[%d.%d.%d] [%d:%d:%d]: %s : %s\r\n",day,month,year,hour,minute,second,SName1,text);
My code -
pawn Код:
stock SName1(playerid)
{
    new SName1[MAX_PLAYER_NAME];
    GetPlayerName(playerid,SName1,sizeof(SName1));
    return SName1;
}

forward SaveToFile(filename[],text[]);
public SaveToFile(filename[],text[])
{

    new File:File, filepath[256], string[256], year,month,day, hour,minute,second;
    getdate(year,month,day); gettime(hour,minute,second);

    format(filepath,sizeof(filepath),"/Suggestions/%s.txt",filename);
    File = fopen(filepath,io_append);
    format(string,sizeof(string),"[%d.%d.%d] [%d:%d:%d]: %s : %s\r\n",day,month,year,hour,minute,second,SName1,text);
    fwrite(File,string);
    fclose(File);
    return 1;
}
What i am actually trying to make ?
Well, i am making a suggestion command so when a player types /suggest an input dialog will appear and whatever the player enter is saved in a file.

Regards,
Ronaldo_raul™
Reply
#2

You forgot to parse a variable to the SName1 function. Also, it's a function so you have to call it suffixed with parenthesis. Also, SName1 is a terrible name for a function.

pawn Код:
// GetName function
stock GetName(playerid) {
    new szName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, szName, MAX_PLAYER_NAME);
    return szName;
}

// Format code
format(string,sizeof(string),"[%d.%d.%d] [%d:%d:%d]: %s : %s\r\n",day,month,year,hour,minute,second,GetName(playerid),text);
Reply
#3

Quote:
Originally Posted by JamesC
Посмотреть сообщение
You forgot to parse a variable to the SName1 function. Also, it's a function so you have to call it suffixed with parenthesis. Also, SName1 is a terrible name for a function.

pawn Код:
// GetName function
stock GetName(playerid) {
    new szName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, szName, MAX_PLAYER_NAME);
    return szName;
}

// Format code
format(string,sizeof(string),"[%d.%d.%d] [%d:%d:%d]: %s : %s\r\n",day,month,year,hour,minute,second,GetName(playerid),text);
C:\Users\Vyom\Desktop\SA-MP 3d\gamemodes\mortals.pwn(17479) : error 017: undefined symbol "playerid"
Reply
#4

Quote:
Originally Posted by Ronaldo_raul™
Посмотреть сообщение
C:\Users\Vyom\Desktop\SA-MP 3d\gamemodes\mortals.pwn(17479) : error 017: undefined symbol "playerid"
On which callback are you putting it on?
Reply
#5

Quote:
Originally Posted by T0pAz
Посмотреть сообщение
On which callback are you putting it on?
GetName(playerid) ?
Reply
#6

Quote:
Originally Posted by Ronaldo_raul™
Посмотреть сообщение
GetName(playerid) ?
Yes.
Reply
#7

i think you have to do this
pawn Код:
forward SaveToFile(playerid,filename[],text[]); // add playerid param in the forward
public SaveToFile(playerid,filename[],text[])  // and here too "this is the callback that you fowarded.
{
    //code
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)