Remake this CMD to ZCMD
#1

Код:
if(playerDB[playerid][vip])
{
        if(!strcmp(cmdtext, "/v ", true,3)){
          if(cmdtext[2]==0){SendClientMessage(playerid,GREEN, "* Naudojimas: /v [tekstas]"); return 1;}
          new zin[256];
          format(zin,sizeof(zin),"VIP: %s",cmdtext[3]);
          SendClientMessageToAll(GREEN,zin);
          return 1;
   }
How to make that CMD to zcmd?
Reply
#2

#include <zcmd>

pawn Код:
//do /v make it to
CMD:v (playerid,params[])
          if(cmdtext[2]==0){SendClientMessage(playerid,GREEN, "* Naudojimas: /v [tekstas]"); return 1;}
          new zin[256];
          format(zin,sizeof(zin),"VIP: %s",cmdtext[3]);
          SendClientMessageToAll(GREEN,zin);
          return 1;
   }
If i helped u please +REP
Reply
#3

C:\Users\Lauryno\Desktop\Servas\gamemodes\bom.pwn( 535) : error 017: undefined symbol "cmdtext"
C:\Users\Lauryno\Desktop\Servas\gamemodes\bom.pwn( 535) : warning 215: expression has no effect
C:\Users\Lauryno\Desktop\Servas\gamemodes\bom.pwn( 535) : error 001: expected token: ";", but found "]"
C:\Users\Lauryno\Desktop\Servas\gamemodes\bom.pwn( 537) : error 021: symbol already defined: "format"
C:\Users\Lauryno\Desktop\Servas\gamemodes\bom.pwn( 539) : error 010: invalid function or declaration
C:\Users\Lauryno\Desktop\Servas\gamemodes\bom.pwn( 541) : warning 203: symbol is never used: "zin"
Reply
#4

pawn Код:
CMD:v (playerid,params[])
{
          if(params[2]==0){SendClientMessage(playerid,GREEN, "* Naudojimas: /v [tekstas]"); return 1;}
          new zin[256];
          format(zin,sizeof(zin),"VIP: %s",params[3]);
          SendClientMessageToAll(GREEN,zin);
          return 1;
}
or else if u use
sscanf

pawn Код:
CMD:v (playerid,params[])
{
          if(sscanf(params,"c",params))return SendClientMessage(playerid,GREEN, "* Naudojimas: /v [tekstas]");
          new zin[256];
          format(zin,sizeof(zin),"VIP: %s",params);
          SendClientMessageToAll(GREEN,zin);
          return 1;
}
Reply
#5

C:\Users\Lauryno\Desktop\Servas\gamemodes\bom.pwn( 536) : error 017: undefined symbol "cmdtext"
C:\Users\Lauryno\Desktop\Servas\gamemodes\bom.pwn( 536) : warning 215: expression has no effect
C:\Users\Lauryno\Desktop\Servas\gamemodes\bom.pwn( 536) : error 001: expected token: ";", but found "]"
C:\Users\Lauryno\Desktop\Servas\gamemodes\bom.pwn( 536) : error 029: invalid expression, assumed zero
C:\Users\Lauryno\Desktop\Servas\gamemodes\bom.pwn( 536) : fatal error 107: too many error messages on one line
Reply
#6

Quote:
Originally Posted by Louris
Посмотреть сообщение
C:\Users\Lauryno\Desktop\Servas\gamemodes\bom.pwn( 536) : error 017: undefined symbol "cmdtext"
C:\Users\Lauryno\Desktop\Servas\gamemodes\bom.pwn( 536) : warning 215: expression has no effect
C:\Users\Lauryno\Desktop\Servas\gamemodes\bom.pwn( 536) : error 001: expected token: ";", but found "]"
C:\Users\Lauryno\Desktop\Servas\gamemodes\bom.pwn( 536) : error 029: invalid expression, assumed zero
C:\Users\Lauryno\Desktop\Servas\gamemodes\bom.pwn( 536) : fatal error 107: too many error messages on one line
edited it...
Reply
#7

Are you using sscanf?
pawn Код:
CMD:v( playerid, params[ ] )
{
    new
        lsText[ 128 ]
    ;
          if ( sscanf( params, "s[128]", lsText ) )
              return SendClientMessage(playerid,GREEN, "* Naudojimas: /v [tekstas]");
          new zin[256];
          format(zin,sizeof(zin),"VIP: %s",lsText);
          SendClientMessageToAll(GREEN,zin);
          return 1;
}
Reply
#8

@Above users, it's params, not cmdtext. Also, it's not necessary to use sscanf for it. That's why there's 'isnull'.
Last, never use a cell of 256 in client/player message. The limit is only 128.
pawn Код:
#define isnull(%1) \
    ((!(%1[0])) || (((%1[0]) == '\1') && (!(%1[1]))))
pawn Код:
CMD:v( playerid, params[ ] )
{
    if( playerDB[ playerid ][ vip ] )
    {
        if( isnull( params ) ) return SendClientMessage( playerid, GREEN, "* Naudojimas: /v [tekstas]" );
        new
            zin[ 128 ]
        ;
        format( zin, sizeof( zin ), "VIP: %s", params );
        SendClientMessageToAll( GREEN, zin );
    }
    return 1;
}
Reply
#9

Quote:
Originally Posted by Edvin
Посмотреть сообщение
Are you using sscanf?
pawn Код:
CMD:v( playerid, params[ ] )
{
    new
        lsText[ 128 ]
    ;
          if ( sscanf( params, "s[128]", lsText ) )
              return SendClientMessage(playerid,GREEN, "* Naudojimas: /v [tekstas]");
          new zin[256];
          format(zin,sizeof(zin),"VIP: %s",lsText);
          SendClientMessageToAll(GREEN,zin);
          return 1;
}
Your script works. But, how to make VIP [NICK_NAME]: message?
Reply
#10

pawn Код:
CMD:v( playerid, params[ ] )
{
    if( playerDB[ playerid ][ vip ] )
    {
        if( isnull( params ) ) return SendClientMessage( playerid, GREEN, "* Naudojimas: /v [tekstas]" );
        new
            zin[ 128 ],
            name[ MAX_PLAYER_NAME ]
        ;
        GetPlayerName( playerid, name, MAX_PLAYER_NAME );
        format( zin, sizeof( zin ), "VIP [%s]: %s", name, params );
        SendClientMessageToAll( GREEN, zin );
    }
    return 1;
}
PS: Wow, everyone ignores the 128 which is the limit. Waste of memory...
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)