SA-MP Forums Archive
Ban help - 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: Ban help (/showthread.php?tid=604258)



Ban help - justjamie - 02.04.2016

Hello,
i have this ban system, but /suspend won't save the ban in the dini file, but /osuspend (offline ban) does.
Can someone help me?
I'm a scripting noob so i have no clue how to do it xd.

pawn Код:
COMMAND:suspend(playerid, params[])
{
    if(!PlayerInfo[playerid][power]) return SendClientError(playerid, CANT_USE_CMD);
    if(strcmp(glob_toban,"NoBodY", true))
    {
        return SendClientError(playerid, "Try again in 1 second!");
    }
    new iPlayer, iReason[ 128 ], iFile[64];
    if( sscanf ( params, "us", iPlayer, iReason))  return SCP(playerid, "[PlayerID/PartOfName] [reason]");
    if(!IsPlayerConnected(iPlayer)) return SendClientError(playerid, PLAYER_NOT_FOUND);
    format(iStr, sizeof(iStr), "[SUSPEND] by %s. Reason: %s", AnonAdmin(playerid), iReason);
    //AdminDB(PlayerName(iPlayer), iStr);
    BanReas(AnonAdmin(playerid),iPlayer,iReason, 0);
    return 1;
}
pawn Код:
COMMAND:osuspend(playerid, params[])
{
    if(!PlayerInfo[playerid][power]) return SendClientError(playerid, CANT_USE_CMD);
/*  if(strcmp(glob_toban,"NoBodY", true))
    {
        return SendClientError(playerid, "Try again in 1 second!");
    }*/

//  iPlayer[ 40 ],
    new iPlayer[ 40 ], iReason[ 128 ], iFile[64];
    if( sscanf ( params, "ss", iPlayer, iReason))  return SCP(playerid, "[Exact_Name] [reason]");
    format(iFile, sizeof(iFile), "%s.dudb.sav.", iPlayer);
    if(dini_Exists(iFile))
    {
        dini_IntSet(iFile,"banned",1);
        dini_Set(iFile,"banreason",iReason);
        dini_Set(iFile,"whobannedme",PlayerName(playerid));
        dini_Set(iFile,"whenigotbanned",TimeDate());
        format(iStr, sizeof(iStr), "[OSUSPEND] by %s. Reason: %s", AnonAdmin(playerid), iReason);
        SendClientInfo(playerid, iStr);
        return 1;
    }
    else
    {
        format(iStr,sizeof(iStr),"\"%s\" (%s) - account not found.",iPlayer,iFile);
        SendClientError(playerid,   iStr);
    }
    return 1;
}



Re: Ban help - Vanter - 02.04.2016

I really can't understand your scripting, also I don't script dini
but
pawn Код:
COMMAND:suspend(playerid, params[])
{
    if(!PlayerInfo[playerid][power]) return SendClientError(playerid, CANT_USE_CMD);
    if(strcmp(glob_toban,"NoBodY", true))
    {
        return SendClientError(playerid, "Try again in 1 second!");
    }
    new iPlayer[MAX_PLAYER_NAME], iReason[ 128 ], iFile[64];
    GetPlayerName(iPlayer,player,sizeof(player));
   
    if( sscanf ( params, "us", iPlayer, iReason))  return SCP(playerid, "[PlayerID/PartOfName] [reason]");
    if(!IsPlayerConnected(iPlayer)) return SendClientError(playerid, PLAYER_NOT_FOUND);

    //SendClientMessages, and also kick them, kick before you set their file to banned, because maybe it would lag if u kick them after

    format(iFile, sizeof(iFile), "%s.dudb.sav.", iPlayer);
    dini_IntSet(iFile,"banned",1);
    dini_Set(iFile,"banreason",iReason);
    dini_Set(iFile,"whobannedme",PlayerName(playerid));
    dini_Set(iFile,"whenigotbanned",TimeDate());\
   
    //format(iStr, sizeof(iStr), "[SUSPEND] by %s. Reason: %s", AnonAdmin(playerid), iReason);
    //BanReas(AnonAdmin(playerid),iPlayer,iReason, 0);
    return 1;
}
try this


Re: Ban help - justjamie - 02.04.2016

Quote:
Originally Posted by Vanter
Посмотреть сообщение
I really can't understand your scripting, also I don't script dini
but
pawn Код:
COMMAND:suspend(playerid, params[])
{
    if(!PlayerInfo[playerid][power]) return SendClientError(playerid, CANT_USE_CMD);
    if(strcmp(glob_toban,"NoBodY", true))
    {
        return SendClientError(playerid, "Try again in 1 second!");
    }
    new iPlayer[MAX_PLAYER_NAME], iReason[ 128 ], iFile[64];
    GetPlayerName(iPlayer,player,sizeof(player));
   
    if( sscanf ( params, "us", iPlayer, iReason))  return SCP(playerid, "[PlayerID/PartOfName] [reason]");
    if(!IsPlayerConnected(iPlayer)) return SendClientError(playerid, PLAYER_NOT_FOUND);

    //SendClientMessages, and also kick them, kick before you set their file to banned, because maybe it would lag if u kick them after

    format(iFile, sizeof(iFile), "%s.dudb.sav.", iPlayer);
    dini_IntSet(iFile,"banned",1);
    dini_Set(iFile,"banreason",iReason);
    dini_Set(iFile,"whobannedme",PlayerName(playerid));
    dini_Set(iFile,"whenigotbanned",TimeDate());\
   
    //format(iStr, sizeof(iStr), "[SUSPEND] by %s. Reason: %s", AnonAdmin(playerid), iReason);
    //BanReas(AnonAdmin(playerid),iPlayer,iReason, 0);
    return 1;
}
try this
Thanks for your concern, but i already figured it out myself.
This was the solution:
pawn Код:
COMMAND:suspend(playerid, params[])
{
    if(!PlayerInfo[playerid][power]) return SendClientError(playerid, CANT_USE_CMD);
    if(strcmp(glob_toban,"NoBodY", true))
    {
        return SendClientError(playerid, "Try again in 1 second!");
    }
    new iPlayer, iReason[ 128 ],  iFile[64];
    if( sscanf ( params, "us", iPlayer, iReason))  return SCP(playerid, "[PlayerID/PartOfName] [reason]");
    if(!IsPlayerConnected(iPlayer)) return SendClientError(playerid, PLAYER_NOT_FOUND);
     format(iFile, sizeof(iFile), "%s.dudb.sav.", PlayerName(playerid));
    if(dini_Exists(iFile))
    {
        dini_Set(iFile,"banreason",iReason);
        dini_Set(iFile,"whobannedme",PlayerName(playerid));
        dini_Set(iFile,"whenigotbanned",TimeDate());
    format(iStr, sizeof(iStr), "[SUSPEND] by %s. Reason: %s", AnonAdmin(playerid), iReason);
        BanReas(AnonAdmin(playerid),iPlayer,iReason, 0);
        SendClientInfo(playerid, iStr);
        return 1;
    }
    else
    {
        format(iStr,sizeof(iStr),"\"%s\" (%s) - account not found.",iPlayer,iFile);
        SendClientError(playerid,   iStr);
    }
    return 1;
}
Thanks for your effort