[HELP] Admin /fine using DCMD/sscanf
#1

Okay here is the Filterscript

Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
	dcmd(fine, 4, cmdtext);
	return 0;
}

dcmd_fine(playerid, params[])
{
	new
		id,
		amount,
		reason,
 		msg;
	if (sscanf(params, "uiz", id, amount, reason)) SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/fine <playerid> <amount> <reason>\"");
******	format(reason, sizeof (reason), "%s has been fined, $%s, for %s", msg[0] ? (""), id : (""), amount : (""), reason); ******
	else if (id == INVALID_PLAYER_ID) SendClientMessage(playerid, 0xFF0000AA, "Player not found");
	else
	{
		GivePlayerMoney(id, -%d);
		SendClientMessageToAll(0xFF0000AA, reason);
		SendClientMessage(0xFF0000AA, "Player Fined");
		return 1;
  }
	return 0;
}
And here is the Errors
Код:
(48) : error 035: argument type mismatch (argument 1)
(48) : error 035: argument type mismatch (argument 1)
(48) : warning 215: expression has no effect
(48) : error 001: expected token: ";", but found "]"
(48) : fatal error 107: too many error messages on one line
Line 48 is surrounded with asterisks
Reply
#2

pawn Код:
dcmd_fine(playerid, params[])
{
    new id,
        amount,
        reason[128],
        playername[MAX_PLAYER_NAME];
   
    if (sscanf(params, "uiz", id, amount, reason))
        SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/fine <playerid> <amount> <reason>\"");
    if (id == INVALID_PLAYER_ID) SendClientMessage(playerid, 0xFF0000AA, "Player not found");
    else
    {
        GetPlayerName(id, playername, MAX_PLAYER_NAME);
        format(reason, 127, "%s has been fined, $%d, for %s", playername, amount, reason);
        GivePlayerMoney(id, -%d);
        SendClientMessageToAll(0xFF0000AA, reason);
        SendClientMessage(0xFF0000AA, "Player Fined");
    }
    return 1;
}
Reply
#3

Thanks for the reply, but that doesn't compile

Here it is.
Код:
34 -ublic OnPlayerCommandText(playerid, cmdtext[])
{
dcmd_fine(playerid, params[])
{
new id,
amount,
reason[128],
playername[MAX_PLAYER_NAME];

if (sscanf(params, "uiz", id, amount, reason))
SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/fine <playerid> <amount> <reason>\"");
if (id == INVALID_PLAYER_ID) SendClientMessage(playerid, 0xFF0000AA, "Player not found");
else
{
GetPlayerName(id, playername, MAX_PLAYER_NAME);
format(reason, 127, "%s has been fined, $%d, for %s", playername, amount, reason);
GivePlayerMoney(id, -);
SendClientMessageToAll(0xFF0000AA, reason);
SendClientMessage(0xFF0000AA, "Player Fined");
}
return 1;
}
	return 0;
57 - }
Код:
(36) : error 017: undefined symbol "dcmd_fine"
(43) : error 017: undefined symbol "params"
(50) : error 029: invalid expression, assumed zero
(50) : error 035: argument type mismatch (argument 2)
(52) : error 035: argument type mismatch (argument 2)
(56) : warning 225: unreachable code
(56) : warning 217: loose indentation
Reply
#4

pawn Код:
dcmd_fine(playerid, params[])
{
    new id,
        amount,
        reason[128],
        playername[MAX_PLAYER_NAME];
   
    if (sscanf(params, "idz", id, amount, reason))
        return SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/fine <playerid> <amount> <reason>\""), 1;
    if ( ! IsPlayerConnected(id) ) SendClientMessage(playerid, 0xFF0000AA, "Player not found");
    else
    {
        GetPlayerName(id, playername, MAX_PLAYER_NAME);
        format(reason, 127, "%s has been fined, $%d, for %s", playername, amount, reason);
        GivePlayerMoney(id, amount);
        SendClientMessageToAll(0xFF0000AA, reason);
        SendClientMessage(playerid, 0xFF0000AA, "Player Fined");
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)