29.08.2009, 15:45
Hi
Yes, it should be declared as separate function.
and yes, if you want create a command with multiple parameters it's recommended to use sscanf.
With zcmd and sscanf /givemoney will look like:
I used ReturnPlayerName in this example which is not native but very useful, if you want use it you may take it here
Quote:
Originally Posted by [B2K
Hustler ]
pawn Code:
|
Quote:
Originally Posted by [B2K
Hustler ]
Right, now that I have that, how do i make a command with multiple parameters for instance, can someone give me an example of lets say, /givemoney <playerid> <amount> command. I haven't worked with dcmd either which may have helped, and also do i need Sscanf? |
With zcmd and sscanf /givemoney will look like:
pawn Code:
#include <zcmd>
#include <sscanf>
zcmd(givemoney, byplayerid, params[]) // btw, it doesn't matter how last 2 parameters are named
{
new
playerid,
money;
if (!sscanf(params, "ii", playerid, money)) // sscanf returns 0 on success
{
new
message[50];
GivePlayerMoney(playerid, money);
format(message, sizeof(message), "You got $%d from %s", money, ReturnPlayerName(byplayerid));
SendClientMessage(playerid, 0x00FF00FF, message);
format(message, sizeof(message), "You gave $%d to %s", money, ReturnPlayerName(playerid));
SendClientMessage(byplayerid, 0xFFFF00FF, message);
}
else SendClientMessage(byplayerid, 0xFFFFFFFF, "Usage: /givemoney <playerid> <amount>");
return 1;
}