problem with self made function
#1

Hello forum, If anyone could explain to me why this small function does not work I would be very thankful, the idea of the function is to return the file location of the player specified.

pawn Код:
stock GetPlayerFile(playerid,filename[])
{
    if(strcmp(filename,"register",0) == 0)// line 13
    {
        new file[256],name[24];
        GetPlayerName(playerid,name,24);
        format(file,sizeof(file),"Register/%s",name);
        return file;
    }
   
}//line 20
I wanted to make my own "filename" parameter for convenience so for the future I can easily access files.

The problem is I get these 2 warnings:

Код:
Line 13: warning 213: tag mismatch
Line 20: warning 209: function "GetPlayerFile" should return a value
Thanks.
Reply
#2

PHP код:
#define PATH "/Register/%s.ini"
stock GetPlayerFile(playerid,filename[])
{
    new 
file[128],name[24];
     
GetPlayerName(playerid,name,24);
      
format(file,sizeof(file),PATH,name);
       return 
file;

Something like that...
Reply
#3

pawn Код:
stock GetPlayerFile(playerid,filename[])
{
    new file[256];
    if(strcmp(filename,"register",false) == 0)
    {
        new name[24];
        GetPlayerName(playerid,name,24);
        format(file,sizeof(file),"Register/%s",name);
    }
    return file;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)