Re: Pawn.CMD - the fastest and most functional command processor -
Max_Andolini - 04.06.2016
Deleted.
Re: Pawn.CMD - the fastest and most functional command processor -
povargek - 04.06.2016
Quote:
Originally Posted by eco1999
|
I'm don't see register a /help command in log
Re: Pawn.CMD - the fastest and most functional command processor -
Max_Andolini - 04.06.2016
Quote:
Originally Posted by povargek
I'm don't see register a /help command in log
|
Example
Re: Pawn.CMD - the fastest and most functional command processor -
vannesenn - 04.06.2016
Where's a include file?
Re: Pawn.CMD - the fastest and most functional command processor -
YourShadow - 04.06.2016
Quote:
Originally Posted by vannesenn
Where's a include file?
|
https://github.com/urShadow/Pawn.CMD...e/Pawn.CMD.inc
Re: Pawn.CMD - the fastest and most functional command processor -
vannesenn - 04.06.2016
Thanks! I hope we'll see something with cmd ids
Re: Pawn.CMD - the fastest and most functional command processor -
Lordzy - 04.06.2016
A feature where command names are dynamically stored with each command having separate index will be useful. Imagine a situation where all commands are supposed to be printed without scanning the whole AMX file.
pawn Код:
//An example if such a feature is implemented.
new
TotalCommands = GetCommandUpperIndex(); //Will return the last command index.
for(new i = 0; i< TotalCommands; i++)
printf("Command : %s", GetCommand(i));
The plugin will have to scan for public names starting with "cmd_" to register it. I have done such a feature for zcmd but that required me to either create an array of command names or to fetch through my AMX file.
Re: Pawn.CMD - the fastest and most functional command processor -
Crayder - 04.06.2016
Quote:
Originally Posted by Lordzy
A feature where command names are dynamically stored with each command having separate index will be useful. Imagine a situation where all commands are supposed to be printed without scanning the whole AMX file.
pawn Код:
//An example if such a feature is implemented. new TotalCommands = GetCommandUpperIndex(); //Will return the last command index. for(new i = 0; i< TotalCommands; i++) printf("Command : %s", GetCommand(i));
The plugin will have to scan for public names starting with "cmd_" to register it. I have done such a feature for zcmd but that required me to either create an array of command names or to fetch through my AMX file.
|
In YCMD it's very simple. Also, in YCMD, commands have permissions. You can even loop through commands that a player is allowed to use.
I suggested permissions above, and it would be great if it was added.
Quote:
Originally Posted by YourShadow
Maybe do something like this:
PHP код:
cmd_id:pm(CMD_PM);
cmd:pm(playerid, params[])
{
return 1;
}
alias:pm("sms");
public OnPlayerCommandReceived(playerid, cmdtext[]) // executed before cmd
{
return 1;
}
public OnPlayerCommandPerformed(playerid, cmd[], params[], cmdid, result) // executed after cmd
{
if (result == -1)
{
SendClientMessage(playerid, 0xFFFFFFFF, "SERVER: Unknown command.");
return;
}
if (cmdid == CMD_PM)
{
//
}
// else if ...
}
?
|
@urShadow, yes that would be fine if commands could have the same ID and there was a 'cmdid' parameter in OnPlayerCommandReceived, then I could do this:
pawn Код:
#define CMD_ADMIN (0b00000001)
#define CMD_VIP (0b00000010)
#define CMD_SUPER (0b00000100)
#define CMD_JAIL (0b00001000)
cmd_id:ban(CMD_ADMIN);
cmd:ban(playerid, params[])
{
return 1;
}
cmd_id:warn(CMD_ADMIN);
cmd:warn(playerid, params[])
{
return 1;
}
cmd_id:car(CMD_VIP | CMD_ADMIN);
cmd:car(playerid, params[])
{
return 1;
}
cmd_id:myhouse(CMD_VIP);
cmd:myhouse(playerid, params[])
{
return 1;
}
new bool:pVIP[MAX_PLAYERS], pAdmin[MAX_PLAYERS];
public OnPlayerCommandReceived(playerid, cmdtext[], cmdid)
{
// Don't allow player to use "car" or "myhouse" unless they are VIP
if((cmdid & CMD_VIP) && !pVIP[playerid]) {
return 0;
}
// Don't allow player to use "ban", "warn", or "car" unless they are Admin
if((cmdid & CMD_ADMIN) && !pAdmin[playerid]) {
return 0;
}
return 1;
}
Re: Pawn.CMD - the fastest and most functional command processor -
Yashas - 05.06.2016
Quote:
Originally Posted by Crayder
That's fair.
|
Quote:
Originally Posted by YourShadow
I will think about it. It is likely that this will affect the performance.
|
It isn't fair. If there are 100 commands, you will first end up checking 100/2th command, i.e: 50th command.
You have to speed test by having two loops, the outer loop being the main iteration loop and the inner loop simulating a call to every command (first to the last).
I haven't checked the source yet but I believe that the engine is doing a binary search.
Re: Pawn.CMD - the fastest and most functional command processor -
YourShadow - 05.06.2016
Quote:
Originally Posted by Yashas
It isn't fair. If there are 100 commands, you will first end up checking 100/2th command, i.e: 50th command.
You have to speed test by having two loops, the outer loop being the main iteration loop and the inner loop simulating a call to every command (first to the last).
I haven't checked the source yet but I believe that the engine is doing a binary search.
|
Calculation a time difference between a reception incoming packet and a command execution - is the only correct way to test.
Re: Pawn.CMD - the fastest and most functional command processor -
xTURBOx - 05.06.2016
just wondering is it possible to do something like this?
GetAllCommandsForDialog() //returns a formatted string of all the cmds
USAGE:
new cmds = GetAllCommandsForDIalog();
ShowPlayerDialog(playerid,DIALOG_CMDS,DIALOG_STYLE _MSGBOX,"Commands",cmds,"Close",""); //create a list of available commands
Re: Pawn.CMD - the fastest and most functional command processor -
Crayder - 05.06.2016
Quote:
Originally Posted by xTURBOx
just wondering is it possible to do something like this?
GetAllCommandsForDialog() //returns a formatted string of all the cmds
USAGE:
new cmds = GetAllCommandsForDIalog();
ShowPlayerDialog(playerid,DIALOG_CMDS,DIALOG_STYLE _MSGBOX,"Commands",cmds,"Close",""); //create a list of available commands
|
That specific format would be dumb.
The best way to do it would be a command ID'ing system, like in YCMD, but that's a little out of the park for this plugin. Scroll up to read more.
Re: Pawn.CMD - the fastest and most functional command processor -
HydraHumza - 06.06.2016
Is it worth to use that?
Re: Pawn.CMD - the fastest and most functional command processor -
Crystallize - 06.06.2016
Quote:
Originally Posted by Crayder
In YCMD it's very simple. Also, in YCMD, commands have permissions. You can even loop through commands that a player is allowed to use.
I suggested permissions above, and it would be great if it was added.
@urShadow, yes that would be fine if commands could have the same ID and there was a 'cmdid' parameter in OnPlayerCommandReceived, then I could do this:
pawn Код:
#define CMD_ADMIN (0b00000001) #define CMD_VIP (0b00000010) #define CMD_SUPER (0b00000100) #define CMD_JAIL (0b00001000)
cmd_id:ban(CMD_ADMIN); cmd:ban(playerid, params[]) { return 1; }
cmd_id:warn(CMD_ADMIN); cmd:warn(playerid, params[]) { return 1; }
cmd_id:car(CMD_VIP | CMD_ADMIN); cmd:car(playerid, params[]) { return 1; }
cmd_id:myhouse(CMD_VIP); cmd:myhouse(playerid, params[]) { return 1; }
new bool:pVIP[MAX_PLAYERS], pAdmin[MAX_PLAYERS];
public OnPlayerCommandReceived(playerid, cmdtext[], cmdid) { // Don't allow player to use "car" or "myhouse" unless they are VIP if((cmdid & CMD_VIP) && !pVIP[playerid]) { return 0; } // Don't allow player to use "ban", "warn", or "car" unless they are Admin if((cmdid & CMD_ADMIN) && !pAdmin[playerid]) { return 0; } return 1; }
|
This would be awesome.
Re: Pawn.CMD - the fastest and most functional command processor -
Crayder - 08.06.2016
Quote:
Originally Posted by Wizzard2H
This would be awesome.
|
For sure, perhaps he should look into it.
Re: Pawn.CMD - the fastest and most functional command processor -
BornHuman - 08.06.2016
Can you still use the old ZCMD method of aliasing commands?
e.g) cmd:help(playerid) return cmd_commands(playerid);
Re: Pawn.CMD - the fastest and most functional command processor -
Crayder - 08.06.2016
Quote:
Originally Posted by BornHuman
Can you still use the old ZCMD method of aliasing commands?
e.g) cmd:help(playerid) return cmd_commands(playerid);
|
Yes, but that's an absolutely horrible way of doing alias commands. You're calling the command help from in game which is going to run all the code to find a public for that help command, then your are calling yet another callback for the other command. This plugin links aliases directly to the correct callback.
Re: Pawn.CMD - the fastest and most functional command processor -
OKStyle - 08.06.2016
urShadow, check your code for return; - not for this language. If plugin in server.cfg not last - other plugins after them not loaded.
Re: Pawn.CMD - the fastest and most functional command processor -
Spmn - 08.06.2016
It is allowed to post memory hacking plugins unless they're harmful (like faking players etc).
However, SA-MP doesn't encourage servers owners to use these type of plugins because they might be incompatible with new SA-MP versions.
Re: Pawn.CMD - the fastest and most functional command processor -
YourShadow - 08.06.2016
Quote:
Originally Posted by OKStyle
If plugin in server.cfg not last - other plugins after them not loaded.
|
Proof, please.