Pawn.CMD.inc
pawncmd.dll
pawncmd.so
#include <Pawn.CMD>
CMD:jetpack(playerid, params[]) // simple command to create a jetpack
{
SetPlayerSpecialAction(playerid, 2);
SendClientMessage(playerid, -1, "Jetpack created successfully.");
return 1;
}
CMD:armour(playerid, params[]) // simple command to create a armour
{
SetPlayerArmour(playerid, 100);
SendClientMessage(playerid, -1, "Armour created successfully.");
return 1;
}
#include <Pawn.CMD>
#include <sscanf2>
CMD:kick(playerid, params[])
{
new ID;
if(sscanf(params, "u", ID)) return SendClientMessage(playerid, -1, "Use /kick [ID]");
if(!IsPlayerConnected(ID)) return SendClientMessage(playerid, -1, "Error, id invalid.");
SendClientMessage(playerid, -1, "Command performed successfully.");
SendClientMessage(ID, -1, "You have been kicked by an admin.");
SetTimerEx("Kickar", 100, false, "i", ID);
return 1;
}
forward Kickar(playerid);
public Kickar(playerid) return Kick(playerid);
CMD:jetpack(playerid, params[]) // simple command to create a jetpack
{
SetPlayerSpecialAction(playerid, 2);
SendClientMessage(playerid, -1, "Jetpack created successfully.");
return 1;
}
alias:jetpack("createjetpack", "cjet"); // /createrjetpack or /cjet has the same function as /jetpack
#include <Pawn.CMD>
#include <sscanf2>
new CMD_ADMIN = 1;
flags:jetpack(CMD_ADMIN); // Use flags:cmd(CMD_ADMIN) to restrict the command, remember to create the constraint in OnPlayerCommandReceived
flags:kick(CMD_ADMIN);
CMD:jetpack(playerid, params[]) // simple command to create a jetpack
{
SetPlayerSpecialAction(playerid, 2);
SendClientMessage(playerid, -1, "Jetpack created successfully.");
return 1;
}
CMD:kick(playerid, params[])
{
new ID;
if(sscanf(params, "u", ID)) return SendClientMessage(playerid, -1, "Use /kick [ID]");
if(!IsPlayerConnected(ID)) return SendClientMessage(playerid, -1, "Error, id invalid.");
SendClientMessage(playerid, -1, "Command performed successfully.");
SendClientMessage(ID, -1, "You have been kicked by an admin.");
SetTimerEx("Kickar", 100, false, "i", ID);
return 1;
}
public OnPlayerCommandReceived(playerid, cmd[], params[], flags)
{
if((flags & CMD_ADMIN) && Admin[playerid] == 0) // You should change "Admin [playerid]" to the admin variable used in your GM.
{
SendClientMessage(playerid, -1, "Error, Command Restricted to Administrators.");
return 0;
}
return 1;
}
public OnPlayerCommandPerformed(playerid, cmd[], params[], result, flags)
{
if(result == -1)
{
SendClientMessage(playerid, -1, "Error, nonexistent command.");
return 0;
}
return 1;
}
Wait wow so i can actually switch THAT EASY from ZCMD to this? it's exactly the same params?
EDIT: freaking awesome thanks to you and Yourshadow for the amazing release. |
Why use the new keyword when the value of it is never modified, just use const keyword instead of new OR use bitwise flags by defining an enumeration and using (<<= 2) with it.
|
@Logic_ What do you mean guy? Cleyson removes the params [] from the commands it does not have.
|
new CMD_ADMIN = 1;
const CMD_ADMIN = 1;
enum (<<=2)
{
CMD_ADMIN = 1, // first one should always start from 1 so the flags are different for each level.
//CMD_ADMIN_LVL1,
//CMD_ADMIN_LVL2,
//...
}
enum (<< = 1)
{
CMD_ADMIN = 1, // first one should always start from 1 so the flags are different for each level because of 0b01
//CMD_ADMIN_LVL1,
//CMD_ADMIN_LVL2,
//...
}
CMD:jetpack(playerid, params[]) // simple command to create a jetpack { SetPlayerSpecialAction(playerid, 2); SendClientMessage(playerid, -1, "Jetpack created successfully."); return 1; } CMD:armour(playerid, params[]) // simple command to create a armour { SetPlayerArmour(playerid, 100); SendClientMessage(playerid, -1, "Armour created successfully."); return 1; }
#define CMD_ADMIN (1)
No, it shouldn't be that either. It should be shown as bits because that's the whole point of the feature...
If you define them as integers like that ("1") then you won't be able set multiple flags, that defeats the purpose. Look at http://forum.sa-mp.com/showpost.php?...&postcount=274 |