Trying to do a macro
#1

Well i read this tutorial, and thought to start making macros,
But now i am getting error's while using them
pawn Код:
#define GetPName(%0)                                         do{new p_name[MAX_PLAYER_NAME]; GetPlayerName(%0,p_name,sizeof(p_name)); return p_name;}
pawn Код:
public OnPlayerConnect(playerid)
{
    format(file,sizeof(file),Userfile,GetPName(playerid));
    return 1;
}
And im getting errors.
Quote:

C:\Users\Admin\Desktop\Untitled.pwn(51) : error 029: invalid expression, assumed zero
C:\Users\Admin\Desktop\Untitled.pwn(51) : error 090: public functions may not return arrays (symbol "OnPlayerConnect")
C:\Users\Admin\Desktop\Untitled.pwn(51) : warning 217: loose indentation
C:\Users\Admin\Desktop\Untitled.pwn(51) : error 029: invalid expression, assumed zero
C:\Users\Admin\Desktop\Untitled.pwn(51) : fatal error 107: too many error messages on one line
Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
4 Errors.

Error line is
pawn Код:
format(file,sizeof(file),Userfile,GetPName(playerid));
Reply
#2

I've tested this. Not sure if it is what you need:
pawn Код:
#define GetPName(%0,%1) new p_name[50], file[256]; GetPlayerName(%0, p_name, 50); format(file, sizeof(file), %1, p_name)
   
public OnPlayerConnect(playerid)
{
    GetPName(playerid, "UserName: %s");
    printf(file);
    return 1;
}
Will print: UserName: [KO]KillerThriller

Just change the "UserName %s" to Userfile then.


Jeffry
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)