26.10.2010, 06:04
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):
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:
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;
}
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;
}