SA-MP Forums Archive
Problem with function - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Problem with function (/showthread.php?tid=496117)



Problem with function - MrTinder - 20.02.2014

I have problem with a function.I wanna in my command /ismuted to show "AdminAction: [BG]MrTinder is muted.Reason: Спам" but at reason it shows my name.

This is the function:

pawn Код:
public GetMuteReason(playerid)
{
    new reason[32];
    if(UserStats[playerid][pMuted] == 1) { reason = "Спам"; }
    else if(UserStats[playerid][pMuted] == 2) { reason = "Псуване/Обиждане"; }
    else if(UserStats[playerid][pMuted] == 3) { reason = "Спам/Псуване/Обиждане"; }
    else if(UserStats[playerid][pMuted] == 4) { reason = "Оплакване във форума"; }
    return 1;
}
this is the command:

pawn Код:
CMD:ismuted(playerid, params[])
{
    new targetID, string[256];
    if(UserStats[playerid][Admin] < 1) return SendClientMessage(playerid, COLOR_GREEN, NOACCESS);
    if(sscanf(params, "u", targetID)) return SendClientMessage(playerid, COLOR_GREEN, "Използвай /ismuted [playerid]");
    if(UserStats[targetID][pMuted] == 0) return SendClientMessage(playerid, COLOR_GREEN, "Този играч не е заглушен");
    else
    {
        format(string, sizeof(string), "AdminAction: %s(ID %d) is muted.Reason: %s", GetName(targetID), targetID, GetMuteReason(targetID));
        SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
    }
    return 1;
}
P.S; I sorry for the strange language ;d

Regards,
S. Ignatov


Re: Problem with function - Konstantinos - 20.02.2014

You should return string and not 1. Remove this line:
pawn Код:
forward GetMuteReason(playerid);
and change with:
pawn Код:
stock GetMuteReason(playerid)
{
    new reason[32];
    switch (UserStats[playerid][pMuted])
    {
        case 1: reason = "Спам";
        case 2: reason = "Псуване/Обиждане";
        case 3: reason = "Спам/Псуване/Обиждане";
        case 4: reason = "Оплакване във форума";
    }
    return reason;
}



Re: Problem with function - MrTinder - 20.02.2014

Thanks bro.