[Resuelto] Crear comandos con 3 o mas parametros.
#1

Hola, si alguien me pudiera ayudar y dar un ejemplo de como hacer un comando con mбs de 3 parametros serнa apreciado.
Ejm:

/y [Player ID] [Commando] [Parametro 1] [Opcional]

/y 14 cambiarvida 70.0

O

/y 16 colorvehiculo verde negro (incluyendo el parametro opcional).

Gracias.
Reply
#2

Osea quieres crear un comando para hacer que otros hagan un comando?
Reply
#3

Si quisiera que alguien hiciera todo por mi, no estarнa pidiendo ayuda, me buscarнa un scripter. Solo necesito un ejemplo para empezar de allн. No tiene que ser el que di, puede ser de cualquier tipo pero con mas de 2 parametros.

Olvidenlo, ya encontre la respuesta:

Quote:
Originally Posted by player007
Here is a demonstration of the method I use for second commands in a command:
pawn Код:
// somewhere on the top of the script:
#define COLOR_RED 0xFF0000AA

dcmd_house(playerid, params[])
{
    new
      cmd2[64], // second command will be stored in this array
      string[128]; // for additional parameters in the second commands (see below)
    if (Account[playerid][pAdminLevel] >= 20) // admin level check
    {
        if (sscanf(params, "s ", cmd2) != 0) // cmd2 will become the first parameter, sscanf is tricked with the extra space to stop processing the string
        {
            // send proper command syntax for player, include only the first parameters (the second commands):
            SendClientMessage(playerid, COLOR_RED, "Usage: /house <add / whatever more params here>");
            return 1; // exit
        }

        if (strcmp("add", cmd2, true, 3) == 0) // check if the first 3 (!) characters of cmd2 are the same as 'add'
        {
            if (sscanf(params, "ss", cmd2, string) != 0) // read the additional parameters after the second command
            {
                // send proper syntax again, now with the needed parameters for the second command the player typed (in this case 'add'):
                SendClientMessage(playerid, COLOR_RED, "Usage: /house <add> <owner>"); // we are expecting only one extra parameter, the 'owner'
                return 1; // exit
            }
            /*
            // you may want to add this extra check for more security ^^
            if (strlen (string) > MAX_PLAYER_NAME) return SendClientMessage(playerid, COLOR_RED, "The given owner name is too long!");
            */

            // command code follows (yours), note that string is now the owner
            new
                Float:x,
                Float:y,
                Float:z,
                Float:angle;
            GetPlayerPos(playerid,x,y,z);
            GetPlayerFacingAngle(playerid,angle);
            AddHouse(owner,x,y,z,GetPlayerVirtualWorld(playerid),GetPlayerInterior(playerid),angle,0/*exitx*/,0/*exity*/,0/*exitz*/,1337/*exitinterior*/,0/*exitangle*/,0/*owned*/,0/*rentable*/,0/*rentcost*/,0/*houseprice*/,0/*locked*/);
            return 1; // successful, exit
        }
        /*
        // additional second commands may come here in this format:
        else if (strcmp("remove", cmd2, true, 6) == 0)
        {
          // check for other params if any
          // check validness of other params
          // code follows
        }
        else if (strcmp("info", cmd2, true, 4) == 0)
        {
          // check for other params if any
          // check validness of other params
          // code follows
        }
        // you may add as many as you want
        */

    }
    /*
    // you may want to send this warning if player if not a level 20 admin:
    else SendClientMessage(playerid, SOME_COLOR, "This is a level 20 admin command!");
    */

    return 1; // end of command
}
This works for me, I use it in multiple commands, hope it helps.
Gracias player007.
Reply
#4

Pues me malentendiste, no te estaba reprochando nada, solo era una pregunta para ver que querias
Reply
#5

Disculpa por la mala respuesta.
Reply
#6

Yo lo necesitarнa para pintar el coche. Pero solo 2 parбmetros.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)