SA-MP Forums Archive
problem with self made function - 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: problem with self made function (/showthread.php?tid=272849)



problem with self made function - mrcoolballs - 30.07.2011

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.


Re: problem with self made function - Kush - 30.07.2011

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...


Re: problem with self made function - MadeMan - 30.07.2011

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