Somethings not working....
#5

First of all, please consider using zcmd.

Also, you don't need to use sscanf to retrieve one string. Use strlen in dcmd (isnull in zcmd):

pawn Код:
dcmd_msg(playerid, params[])
{
    new
        input[21],
        string[60];
    if (strlen(params)) SendClientMessage(playerid, 0xFF0000AA, "Usage: /msg [msg]"); // Check cmd length
    else
    {
        Msg[playerid] = input[0];
        Created[playerid] = 1;
    }
    return 1;
}
The reason that you're only getting the first letter of your message is simply because you're retrieving the first cell (which is the first letter). Also I fail to see why you've created variable 'Created', you can just format the string to say "Nothing" and use strcmp to check whether it says nothing. There's no need at all to create another player array (you're wasting 2000 bytes of memory).

Use strmid to put your message in to a string.

Personally, I would find that using a PVar string would be more sufficient for this operation, seeing as you're setting a string (despite the fact that PVars are a bit slower than regular arrays), I've provided an efficient example below:

pawn Код:
CMD:msg(playerid, params[]) { // zcmd
    if(isnull(params)) return SendClientMessage(playerid, 0xFF0000AA, "Usage: /msg [msg]"); // Check command

    // Going by the string you set in OnPlayerDeath, a 60 character limit.
    if(strlen(params) < 61) SetPVarString(playerid, "pMsg", params); // Check length, if exceeds 60, message won't set
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason) {
    new string[60];

    if(GetPVarType(playerid, "pMsg") != 0) { // Check if PVar type is not 0. If it is, a message is not set.
        GetPVarString(playerid, "pMsg", string, sizeof(string)); // Retrieve the PVar string
        GameTextForPlayer(playerid, string, 5000, 6); // Send your gametext out.
    }
    return 1;
}
Reply


Messages In This Thread
Somethings not working.... - by Lorenc_ - 25.10.2010, 19:59
Re: Somethings not working.... - by randomkid88 - 25.10.2010, 20:32
Re: Somethings not working.... - by Fj0rtizFredde - 25.10.2010, 20:32
Re: Somethings not working.... - by Lorenc_ - 26.10.2010, 05:52
Re: Somethings not working.... - by Calgon - 26.10.2010, 06:04
Re: Somethings not working.... - by Lorenc_ - 26.10.2010, 06:24
Re: Somethings not working.... - by Calgon - 26.10.2010, 06:26

Forum Jump:


Users browsing this thread: 2 Guest(s)