[HELP] ZCMD
#1

Hey everyone,

This is ZCMD command that I coverted from strcmp one. When it was strcmp everything worked well. But now when I write In-Game: "/b very long text that I'm writing to check if everything is correct." it shows me just: " very long text that I'm writing ". I don't get it why is it so?

pawn Код:
CMD:b(playerid, params[])
{
    if (sscanf(params, "s", params)) return SendClientMessage(playerid, COLOR_GREY, "Usage: /b [text]");
    new str[128];
    new Float:x, Float:y, Float:z;

    GetPlayerName(playerid, str, sizeof(str));
    GetPlayerPos(playerid, x, y, z);

    format(str, sizeof(str), "(( %s says: %s ))", str, params);
    ProxDetector(10.0, playerid, str, COLOR_GREY,COLOR_GREY,COLOR_GREY,COLOR_GREY,COLOR_GREY);
    SendClientMessage(playerid, COLOR_YELLOW, params);
    return 1;
}
Reply
#2

You store the player name but also the message in the array "str", you can create another array to store the player name, also you don't need sscanf you can just use the isnull keyword -

pawn Код:
CMD:b(playerid, params[])
{
    if ( isnull ( params ) ) return SendClientMessage(playerid, COLOR_GREY, "Usage: /b [text]");
    new
        str[ 128 ],
        player_name[ MAX_PLAYER_NAME ],
        Float:x,
        Float:y,
        Float:z;

    GetPlayerName( playerid, player_name, MAX_PLAYER_NAME );
    GetPlayerPos(playerid, x, y, z);

    format(str, sizeof(str), "(( %s says: %s ))", player_name, params);
    ProxDetector(10.0, playerid, str, COLOR_GREY,COLOR_GREY,COLOR_GREY,COLOR_GREY,COLOR_GREY);
    SendClientMessage(playerid, COLOR_YELLOW, params);
    return 1;
}
Reply
#3

Well for one thing there's no need to be using sscanf when you're not splitting anything. You need a function like strlen is isnull, for example:

pawn Код:
if(isnull(params)) return SendClientMessage(playerid, COLOR_GREY, "Usage:....");
sscanf is meant to un-format strings, not meant to check if a string isn't empty.

What the person said above me technically doesn't matter, as it would still work the way you did it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)