SA-MP Forums Archive
Trying to do a macro - 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: Trying to do a macro (/showthread.php?tid=260359)



Trying to do a macro - [KO]KillerThriller - 08.06.2011

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



Re: Trying to do a macro - Jeffry - 08.06.2011

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