16.08.2009, 19:10
Wait
is it like zcmd
is it like zcmd
public OnPlayerCommandText(playerid, cmdtext[])
{
if(IsPlayerConnected(playerid) && gPlayerLogged[playerid] == 1)
{
...
dcmd(bla,3,cmdtext);
...
}
else
{
SendClientMessage(playerid,COLOR_RED,"[INFO:] Your not logged in, therefore you can not use any commands.");
SendClientMessage(playerid,COLOR_RED,"[INFO:] Type your password to register/login.");
return 1;
}
return 0;
}
zcmd(lol,playerid,params[])
{
#pragma unused params
SendClientMessage(playerid,COLOR_WHITE,"It works");
return 1;
}
#define ZCMD_NO_CALLBACK
#include <zcmd>
public OnPlayerCommandText(playerid, cmdtext[])
{
if (IsPlayerConnected(playerid) && gPlayerLogged[playerid] == 1)
{
return ZCMD_ProcessCommand(playerid, cmdtext);
}
SendClientMessage(playerid,COLOR_RED,"[INFO:] Your not logged in, therefore you can not use any commands.");
SendClientMessage(playerid,COLOR_RED,"[INFO:] Type your password to register/login.");
return 1;
}
#include <zcmd>
public OnPlayerCommandText(playerid, cmdtext[])
{
if (!IsPlayerConnected(playerid) || gPlayerLogged[playerid] != 1)
{
SendClientMessage(playerid,COLOR_RED,"[INFO:] Your not logged in, therefore you can not use any commands.");
SendClientMessage(playerid,COLOR_RED,"[INFO:] Type your password to register/login.");
return 1;
}
return 0;
}
...
ZCMD_ProcessCommand(playerid, cmdtext);
...
dcmd_l(playerid, params[])
{
return dcmd_local(playerid, params);
}
...(5560) : error 029: invalid expression, assumed zero ...(5560) : error 029: invalid expression, assumed zero ...(5561) : warning 209: function "zcmd_local" should return a value |
zcmd(l,playerid,params[])
{
return zcmd(local,playerid, params);
}
zcmd(local,playerid,cmdtext[])
{
....
return 1;
}
zcmd(l,playerid,params[])
{
return zcmd_local(playerid, params);
}
zcmd(local,playerid,cmdtext[])
{
....
return 1;
}
#include <zcmd>
zcmd(mycommand, playerid, params[])
{
// Do something
return 1;
}
Originally Posted by [B2K
Hustler ]
pawn Code:
|
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? |
#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;
}
zcmd(givemoney, byplayerid, params[]) // btw it doesn't matter how last 2 parameters are named
zcmd(commandname, what is this, params[]) // btw it doesn't matter how last 2 parameters are named
new byplayerid; //?
else SendClientMessage(byplayerid, 0xFFFFFFFF, "Usage: /givemoney <playerid> <amount>");
Originally Posted by [B2K
Hustler ]
I know it is: pawn Код:
pawn Код:
|
Originally Posted by [B2K
Hustler ]
Also, does the else statement execute if either parameters are not completed, or just the first one, and does it show this message if the format is incoorect, for instance if i type /givemoney 21 hello? pawn Код:
|
Originally Posted by Dabombber
Quote:
pawn Код:
Quote:
Somewhat releated, what about using pawn Код:
|
dcmd_callthiscommand(playerid, params);
zcmd(phone, playerid, params[])
zcmd(phone, playerid, params)
zcmd(shortcommand, playerid, params[])
{
return zcmd_longcommand(playerid, params);
}
dcmd_callthiscommand(playerid, params);
zcmd_callthiscommand(playerid, params);
zcmd(phone, playerid, params[])
Originally Posted by |№іі7
Can you explain how I can return my own Unknown command message? while having the commands in a separate function though.
|
public OnPlayerCommandText(playerid, cmdtext[])
{
if (!ZCMD_ProcessCommand(playerid, cmdtext))
{
SendClientMessage(playerid, 0xFF0000FF, "Unknown command");
}
return 1;
}
#define ZCMD:%1(%2) forward zcmd_%1(%2);public zcmd_%1(%2)
ZCMD:ban(playerid, cmdtext[])
{
// Code goes here
}