Macro - Code after body
#6

Quote:
Originally Posted by ******
Посмотреть сообщение
Yes and no. You can't make "makeadmin" upper-case, so you can only generate code with "PERMISSION_COMMAND_makeadmin". If that will do you have:

pawn Код:
#define ACMD:%0(%1) CMD:%0(%1) if (!IsAdmin(playerid, PERMISSION_COMMAND_%0)) return COMMAND_PERMISSION_DENIED; else
The other solution is to write every command in uppercase.

Код:
ACMD:MAKEADMIN(playerid, params[])
Hmm, or another way:

Код:
#define ACMD:%0(%1,%2,%3) CMD:%0(%1, %2) if (!IsAdmin(playerid, %3)) return COMMAND_PERMISSION_DENIED; else
Pro: I can use permission groups like PERMISSION_SERVERADMIN to set one permission for multiple commands.

Contra: I have to add the required permission constant to each command.


//EDIT: Ok, that works.

But this will crash the compiler:
Код:
#define ACMD:%0(%1,%2,%3) COMMAND:%0(%1, %2) if (!HasPermission(%1, PERMISSION_%3)) return COMMAND_PERMISSION_DENIED; else
I've changed IsAdmin to HasPermission and CMD to COMMAND. CMD is just an alias of COMMAND in zcmd.
If I change "PERMISSION_%3" to "%3" it works...

// EDIT 2: I found the problem. There is a space before %3... Is there a way to remove it without removing the space everywhere?
Reply


Messages In This Thread
Macro - Code after body - by Programie - 20.02.2012, 13:53
Re: Macro - Code after body - by MP2 - 20.02.2012, 13:55
Re: Macro - Code after body - by Programie - 20.02.2012, 13:56
Re: Macro - Code after body - by Cameltoe - 20.02.2012, 14:02
Re: Macro - Code after body - by Programie - 20.02.2012, 14:04
Re: Macro - Code after body - by Programie - 20.02.2012, 14:44
Re: Macro - Code after body - by Programie - 20.02.2012, 16:34
Re: Macro - Code after body - by Programie - 20.02.2012, 16:47

Forum Jump:


Users browsing this thread: 1 Guest(s)