Two similar commands with ZCMD
#1

Hello !

I use ZCMD plugin for my commands.

I have for example this command :

PHP код:
CMD:skin(playeridparams[]) {
    new 
skin;
    if(
sscanf(params"i"skin) || skin || skin 299exception(playeridERROR_USE"/skin <skinid [0-299]>");
    else { 
SetPlayerSkin(playeridskin); log(playeridTYPE_COMMANDE_ADMINcompressCommand("skin"params)); }
    return 
1;

To shorten, I would like the /s <skinid> commanddo the same thing as /skin <skinid>.

Have I any other solution than put the same code in the two commands or do a function that I call in the two commands ?

Thanks in advance and sorry for my probably bad english
Reply
#2

I'm sure VincentDunn will help!
Reply
#3

pawn Код:
CMD:s(playerid, params) return cmd_skin(playerid, params[]);
CMD:skin(playerid, params[])
{
    new skin = strval(params);
    if(isnull(params) || skin > 299 || skin < 0) {
        return exception(playerid, ERROR_USE, "/skin <skinid [0-299]>");
    }
    SetPlayerSkin(playerid, skin);
    log(playerid, TYPE_COMMANDE_ADMIN, compressCommand("skin", params));
    return 1;
}
Reply
#4

Quote:
Originally Posted by VincentDunn
Посмотреть сообщение
pawn Код:
CMD:s(playerid, params) return cmd_skin(playerid, params[]);
CMD:skin(playerid, params[])
{
    new skin = strval(params);
    if(isnull(params) || skin > 299 || skin < 0) {
        return exception(playerid, ERROR_USE, "/skin <skinid [0-299]>");
    }
    SetPlayerSkin(playerid, skin);
    log(playerid, TYPE_COMMANDE_ADMIN, compressCommand("skin", params));
    return 1;
}
Man i didn't know that i can do this!
Reply
#5

Thank you!

You're just wrong, the correct code is this:

PHP код:
CMD:s(playeridparams[]) return cmd_skin(playeridparams); // Inattention ;D
CMD:skin(playeridparams[])
{
    new 
skin strval(params);
    if(
isnull(params) || skin 299 || skin 0) {
        return 
exception(playeridERROR_USE"/skin <skinid [0-299]>");
    }
    
SetPlayerSkin(playeridskin);
    
log(playeridTYPE_COMMANDE_ADMINcompressCommand("skin"params));
    return 
1;

it works, thank you
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)