Y_INI Writing Problem
#1

Hey, so i am working on a mute system. I have a Saving/Loading system on it. Here are my codes:

Saving:
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,"data");
    INI_WriteInt(File,"Muted",PlayerInfo[playerid][Muted]);
    INI_WriteString(File,"MutedReason",PlayerInfo[playerid][MutedReason]);
    INI_WriteInt(File,"MuteWarnings",PlayerInfo[playerid][MuteWarnings]);
    INI_WriteInt(File,"SpamMute",PlayerInfo[playerid][SpamMute]);
    INI_WriteInt(File,"TotalMute",PlayerInfo[playerid][TotalMute]);
    INI_Close(File);

    return 1;
}
Saving and Loading OnPlayerConnect
pawn Код:
public OnPlayerConnect(playerid)
{
    if(fexist(UserPath(playerid)))
    {
        INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
    }
    else
    {
        new INI:File = INI_Open(UserPath(playerid));
        INI_SetTag(File,"data");
        INI_WriteInt(File,"Muted",0);
        INI_WriteString(File,"MutedReason", "0");
        INI_WriteInt(File,"MuteWarnings",0);
        INI_WriteInt(File,"SpamMute", 0);
        INI_WriteInt(File,"TotalMute",0);
        INI_Close(File);
    }
    return 1;
}
Loading:
pawn Код:
forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
    INI_Int("Muted",PlayerInfo[playerid][Muted]);
    INI_String("MutedReason",PlayerInfo[playerid][MutedReason], 70);
    INI_Int("MuteWarnings",PlayerInfo[playerid][MuteWarnings]);
    INI_Int("SpamMute",PlayerInfo[playerid][SpamMute]);
    INI_Int("TotalMute",PlayerInfo[playerid][TotalMute]);
    return 1;
}
I have a mute spam kick system and mute and unmute commands.

pawn Код:
public OnPlayerText(playerid, text[])
{
    if (PlayerInfo[playerid][Muted] == 1){
        PlayerInfo[playerid][MuteWarnings]++;
        new msg1[128];
        format(msg1, sizeof(msg1), "* You're Muted, You can't talk. (Warnings: %d/%d)", PlayerInfo[playerid][MuteWarnings], MAX_WARNINGS);
        SendClientMessage(playerid, COLOR_YELLOW, msg1);
        if (PlayerInfo[playerid][MuteWarnings] >= MAX_WARNINGS) {
            new msg2[128], name[MAX_PLAYER_NAME];
            SendClientMessage(playerid, COLOR_RED, "* You've been kicked due to Mute spamming!");
            PlayerInfo[playerid][Muted] = 0;
            PlayerInfo[playerid][MuteWarnings] = 0;
            PlayerInfo[playerid][MutedReason] = "0"; // Line 110
            SetTimerEx("KickDelay", 1000, false, "d", playerid);
            GetPlayerName(playerid,name, sizeof(name));
            format(msg2, sizeof(msg2), "[KICK]: %s has been kicked [Reason: Mute Spamming].", name);
            SendClientMessageToAll(COLOR_YELLOW, msg2);
        }
        return 0;
    }
    return 1;
}
CMD:unmute(playerid, params[]) {
    if (IsPlayerAdmin(playerid)) {
        new targetid, aname[MAX_PLAYER_NAME], tname[MAX_PLAYER_NAME], msg1[128];
        if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, COLOR_LIGHTBLUE,"[USAGE]: /unmute [playerid]" );
        if(targetid == INVALID_PLAYER_ID) return SendClientMessage( playerid, COLOR_RED,"[ERROR]: Player Is Not Connected!" );
        if (!IsPlayerMuted(playerid)) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: That player is not muted.");

        GetPlayerName(playerid, aname, sizeof(aname));
        GetPlayerName(targetid, tname, sizeof(tname));

        format(msg1, sizeof(msg1), "* Administrator %s has unmuted %s.", aname, tname);
        SendClientMessageToAll(COLOR_LIGHTBLUE, msg1);
        PlayerInfo[targetid][Muted] = 0;
        PlayerInfo[targetid][MutedReason] = "-1"; // Line 205
        PlayerInfo[targetid][MuteWarnings] = 0;
        PlayerInfo[targetid][SpamMute] = 0;
        PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
        PlayerPlaySound(targetid,1057,0.0,0.0,0.0);

    } else {
        SendClientMessage(playerid, COLOR_RED, "* Only admins can use that command.");
    }
    return 1;
}
And i get these error:

pawn Код:
C:\Users\ReBzz\Desktop\DarkSkull TDM\filterscripts\AMS.pwn(110) : error 047: array sizes do not match, or destination array is too small
C:\Users\ReBzz\Desktop\DarkSkull TDM\filterscripts\AMS.pwn(205) : error 047: array sizes do not match, or destination array is too small
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


2 Errors.
Need Help ASAP.
Reply
#2

Try replacing "PlayerInfo[playerid][MutedReason] = "0" ; //Line 110 with - strmid(PlayerInfo[playerid][MutedReason, 0, 0, 0, 225);

I've not tested this yet, but this worked for me out too.
Reply
#3

Could you explain what it does...?
Reply
#4

Read it about it here : Click Here
Reply
#5

Ok Let me try that.

EDIT: Nope that did not work. It gives me argument type mismatch. Please Help
Reply
#6

I fixed it. I replaced the error line with this.

pawn Код:
format(PlayerInfo[playerid][MutedReason], 128, "0");
I also replaced the reason in mute code to:

pawn Код:
format(PlayerInfo[playerid][MutedReason], 128, "%s", reason);
But now here is what it saves.
pawn Код:
[data]
Muted = 1
MutedReason = G* Administrator DarkSkull has muted DarkSkull. [Reason: Gohome]
MuteWarnings = 0
SpamMute = 0
TotalMute = 3
Mute Code:
pawn Код:
CMD:mute(playerid, params[]) {
    if (IsPlayerAdmin(playerid)) {
        new targetid, aname[MAX_PLAYER_NAME], tname[MAX_PLAYER_NAME], msg1[128], reason;
        if(sscanf(params, "us[64]", targetid, reason)) return SendClientMessage(playerid, COLOR_LIGHTBLUE,"[USAGE]: /mute [playerid] [reason]" );
        if(targetid == INVALID_PLAYER_ID) return SendClientMessage( playerid, COLOR_RED,"[ERROR]: Player Is Not Connected!" );
        if (IsPlayerMuted(playerid)) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: That player is already muted.");

        GetPlayerName(playerid, aname, sizeof(aname));
        GetPlayerName(targetid, tname, sizeof(tname));

        format(msg1, sizeof(msg1), "* Administrator %s has muted %s. [Reason: %s]", aname, tname, reason);
        SendClientMessageToAll(COLOR_LIGHTBLUE, msg1);
        PlayerInfo[targetid][Muted] = 1;
        format(PlayerInfo[playerid][MutedReason], 128, "%s", reason); // Here is what changed
        PlayerInfo[targetid][MuteWarnings] = 0;
        PlayerInfo[targetid][SpamMute] = 0;
        PlayerInfo[targetid][TotalMute]++;
        PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
        PlayerPlaySound(targetid,1057,0.0,0.0,0.0);

    } else {
        SendClientMessage(playerid, COLOR_RED, "* Only admins can use that command.");
    }
    return 1;
}
Reply
#7

BUMP.. Please help Me...
Reply
#8

Try to change the PlayerInfo[playerid][MutedReason] size to 64.
Reply
#9

If that's how you reset a string than you are completely wrong.
Use PlayerInfo[playerid][MutedReason][0] = '\0'
Reply
#10

Ok.. Let me try.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)