[Plugin] Pawn.CMD
#61

Deleted.
Reply
#62

Quote:
Originally Posted by eco1999
Посмотреть сообщение
I'm don't see register a /help command in log
Reply
#63

Quote:
Originally Posted by povargek
Посмотреть сообщение
I'm don't see register a /help command in log
Example
Reply
#64

Where's a include file?
Reply
#65

Quote:
Originally Posted by vannesenn
Посмотреть сообщение
Where's a include file?
https://github.com/urShadow/Pawn.CMD...e/Pawn.CMD.inc
Reply
#66

Thanks! I hope we'll see something with cmd ids
Reply
#67

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.
Reply
#68

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(playeridparams[])
{
    return 
1;
}
alias:pm("sms");
public 
OnPlayerCommandReceived(playeridcmdtext[]) // executed before cmd
{
    return 
1;
}
public 
OnPlayerCommandPerformed(playeridcmd[], params[], cmdidresult// executed after cmd
{
    if (
result == -1)
    {
        
SendClientMessage(playerid0xFFFFFFFF"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;
}
Reply
#69

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.
Reply
#70

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.
Reply
#71

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
Reply
#72

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.
Reply
#73

Is it worth to use that?
Reply
#74

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.
Reply
#75

Quote:
Originally Posted by Wizzard2H
Посмотреть сообщение
This would be awesome.
For sure, perhaps he should look into it.
Reply
#76

Can you still use the old ZCMD method of aliasing commands?

e.g) cmd:help(playerid) return cmd_commands(playerid);
Reply
#77

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.
Reply
#78

urShadow, check your code for return; - not for this language. If plugin in server.cfg not last - other plugins after them not loaded.
Reply
#79

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.
Reply
#80

Quote:
Originally Posted by OKStyle
Посмотреть сообщение
If plugin in server.cfg not last - other plugins after them not loaded.
Proof, please.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)