Posts: 607
	Threads: 90
	Joined: Feb 2011
	
Reputation: 
0
	 
 
	
	
		Thanks! I hope we'll see something with cmd ids
	
	
	
	
		
	
 
 
	
	
	
		
	Posts: 3,324
	Threads: 96
	Joined: Sep 2013
	
	
 
	
	
		
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;
}
 
	 
	
	
	
		
	
 
 
	
	
	
		
	Posts: 378
	Threads: 29
	Joined: Aug 2015
	
Reputation: 
0
	 
 
	
	
		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
	
	
	
	
		
	
 
 
	
	
	
		
	Posts: 3,324
	Threads: 96
	Joined: Sep 2013
	
	
 
	
	
		
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.
	
 
	
	
	
		
	
 
 
	
	
	
		
	Posts: 1,498
	Threads: 110
	Joined: Aug 2013
	
	
 
	
	
		
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.
	
 
	
	
	
		
	
 
 
	
	
	
		
	Posts: 3,324
	Threads: 96
	Joined: Sep 2013
	
	
 
	
	
		
Quote:
					Originally Posted by  Wizzard2H
 
 
This would be awesome. 
 | 
 For sure, perhaps he should look into it.
	
 
	
	
	
		
	
 
 
	
	
	
		
	Posts: 347
	Threads: 78
	Joined: Sep 2013
	
Reputation: 
0
	 
 
	
	
		Can you still use the old ZCMD method of aliasing commands?
e.g) cmd:help(playerid) return cmd_commands(playerid);
	
	
	
	
		
	
 
 
	
	
	
		
	Posts: 3,324
	Threads: 96
	Joined: Sep 2013
	
	
 
	
	
		
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.
	
 
	
	
	
		
	
 
 
	
	
	
		
	Posts: 3,138
	Threads: 71
	Joined: May 2008
	
Reputation: 
0
	 
 
	
	
		urShadow, check your code for return; - not for this language. If plugin in server.cfg not last - other plugins after them not loaded.
	
	
	
	
		
	
 
 
	
	
	
		
	Posts: 513
	Threads: 4
	Joined: Jun 2015
	
Reputation: 
0
	 
 
	
	
		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.