Some some "INI_WriteInt" questions
#1

Well, since i failed at a "INI_WriteInt" attempt, i have some questions(Mostly about saving ban logs)

1) Do i need to create a new path for when the player was banned?
For an example:

#define BANLOG "/AdminInfo/BanLogs/%s.ini"

So, that would save the Name.ini ban info in the -> scriptfiles/AdminInfo/BanLogs/Name.ini, right?

And the, at the /ban command, what do i do there?

format(string....) didn't work(lol) xd

2) Is there a way to save it in the current players path?

#define PATH "/Users/%s.ini"

And then just add the ban-info to his current info..?
Reply
#2

1)
Yes it will save his name in ban lists
2)
Ofc, add to your pinfo enum
pawn Код:
Banned,
Then when a player is banned like if you use sscanf
pawn Код:
new id;
new reason;
if(sscanf(params, "us", id, reason)) return // etc
Ban(id);
PlayerInfo[playerid][Banned] = 1;
now it will output Banned = 1 in player's txt file if he's banned
About the bans file you can add ban info (reason, ip , name)
You can use one of these.
P.S PlayerInfo is not the variable you use right? anyways, Like that
You can ask more questions if you like
Reply
#3

Quote:
Originally Posted by Sawalha
Посмотреть сообщение
1)
Yes it will save his name in ban lists
2)
Ofc, add to your pinfo enum
pawn Код:
Banned,
Then when a player is banned like if you use sscanf
pawn Код:
new id;
new reason;
if(sscanf(params, "us", id, reason)) return // etc
Ban(id);
PlayerInfo[playerid][Banned] = 1;
now it will output Banned = 1 in player's txt file if he's banned
About the bans file you can add ban info (reason, ip , name)
You can use one of these.
P.S PlayerInfo is not the variable you use right? anyways, Like that
You can ask more questions if you like
About the 1st one..
Do i just add
"pName || pBanReason" to the enums? xd

Hah, I'm actually not so good with some part at the Y_INI stuff.., so most of my questions will sound dumb.

But uh, how do i exactly save the Ban Reason etc in his user files?
For an example:

pawn Код:
Password = 173081214
Cash = 0
Admin = 0
Kills = 0
Deaths = 0
Score = 0
Muted = 0
VIP = 0
Reward = 0
TempAdmin = 0
IP = 15
LoggedIn = 0
TimesWarned = 0
TimeKicked = 0
Banned = 0
OriginalName = 0
Jailed = 0
ACBanned = 1
FailedRCON = 0
ACDetected = 0

[B]BannedBy = NAMEHERE
BanReason = REASONHERE[/B]
Reply
#4

Sorry for late mate here's the whole command:
pawn Код:
CMD:ban(playerid, params[])
{
    new id;
    new reason;
    new name[MAX_PLAYER_NAME];
    new aname[MAX_PLAYER_NAME];
    new string[128];
    if(sscanf(params, "us", id, reason)) return SendClientMessage(playerid, RED, "Usage /ban [playerid] [reason]");
    if(PlayerInfo[playerid][Admin] >= 2) // you can change the "2" for level you like//
    {
        GetPlayerName(id, name, sizeof(name));
        GetPlayerName(playerid, aname, sizeof(aname));
        format(string, sizeof(string), "You have been banned by Administrator %s [Reason: %s]", aname, reason);
        SendClientMessage(id, RED, string);
        Ban(playerid);
        PlayerInfo[playerid][Banned] = 1;
        new INI:File = INI_Open(UserPath(playerid));
        INI_WriteString("Banned By", aname);
        INI_WriteString("Reason", reason);
        INI_Close(File);
    }
    else return SendClientMessage(playerid, RED, "You are not high enough level to use this command");
    return 1;
}
Add this stock:
pawn Код:
stock UserPath(playerid)
{
    new string[128]; new name[MAX_PLAYER_NAME]; GetPlayerName(playerid, name, sizeof(name));
    format(string, sizeof(string), PATH, name);
    return string;
}
and change PATH to Users/%s.ini
if anything dosen't work, tell me.
Reply
#5

Quote:
Originally Posted by Sawalha
Посмотреть сообщение
Sorry for late mate here's the whole command:
pawn Код:
CMD:ban(playerid, params[])
{
    new id;
    new reason;
    new name[MAX_PLAYER_NAME];
    new aname[MAX_PLAYER_NAME];
    new string[128];
    if(sscanf(params, "us", id, reason)) return SendClientMessage(playerid, RED, "Usage /ban [playerid] [reason]");
    if(PlayerInfo[playerid][Admin] >= 2) // you can change the "2" for level you like//
    {
        GetPlayerName(id, name, sizeof(name));
        GetPlayerName(playerid, aname, sizeof(aname));
        format(string, sizeof(string), "You have been banned by Administrator %s [Reason: %s]", aname, reason);
        SendClientMessage(id, RED, string);
        Ban(playerid);
        PlayerInfo[playerid][Banned] = 1;
        new INI:File = INI_Open(UserPath(playerid));
        INI_WriteString("Banned By", aname);
        INI_WriteString("Reason", reason);
        INI_Close(File);
    }
    else return SendClientMessage(playerid, RED, "You are not high enough level to use this command");
    return 1;
}
Add this stock:
pawn Код:
stock UserPath(playerid)
{
    new string[128]; new name[MAX_PLAYER_NAME]; GetPlayerName(playerid, name, sizeof(name));
    format(string, sizeof(string), PATH, name);
    return string;
}
and change PATH to Users/%s.ini
if anything dosen't work, tell me.
I already have the UserPath:

pawn Код:
stock UserPath(playerid)
{
    new string[128],playername[MAX_PLAYER_NAME];
    GetPlayerName(playerid,playername,sizeof(playername));
    format(string,sizeof(string),PATH,playername);
    return string;
}
It's the same

Well, Here's my version of the ban command:

pawn Код:
CMD:ban(playerid, params[]) {
    new id; //'defines' the targets id.
    new reason[50]; //'defines' the reason.
    if(PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playerid, COLOR_RED, "[ADMIN] - Only admins can use command!"); //if player isn't a rcon admin, he will receive this "error" message.
    if(sscanf(params, "us[50]", id, reason)) return SendClientMessage(playerid, COLOR_ORANGE, "[USAGE] - /ban [ID] [Reason]"); //if there are missing parameters, the admin will receive the usage of this command.
    if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_ORANGE, "[NOTE] - Player not found."); //If the targets id isnt found, the admin will receive this message (Player Not found).
    if(PlayerInfo[id][pAdmin] == 7) return SendClientMessage(playerid, COLOR_RED, "* One does not simply ban the server owner!");

    new string[150], sender[MAX_PLAYER_NAME], receiver[MAX_PLAYER_NAME]; //thanks to this, everyone will be able to see who was kicked, and by who.
    GetPlayerName(playerid, sender, sizeof(sender)); //Gets the senders(admins) name/id.
    GetPlayerName(id, receiver, sizeof(receiver)); //Gets the receivers(targets) name/id.
    format(string, sizeof(string), "[BAN] - %s(%d) has been banned by %s(%d)", receiver, id, sender, playerid);
    SendClientMessageToAll(COLOR_RED, string); //Sends the kick message, as seen above ^.
    format(string, sizeof(string), "[BAN] - Reason: %s", reason);
    SendClientMessageToAll(COLOR_RED, string); //Sends the kick reasons message, as seen above ^
    SetTimerEx("BanTimer", 500, false, "i", id); //Sets KickTimer to 1 seond(will be kicked after 1 second)
    PlayerInfo[id][pBanned] = 1;
    SendClientMessage(id, COLOR_ORANGE, "[BAN] - You've been BANNED"); //Sends Target a message, saying that he was kicked.
    SendClientMessage(id, COLOR_ORANGE, "[BAN] - For more info read the chat.");
    format(string, sizeof(string), "[ADMIN] - %s[%d] has used BAN on %s[%d]", sender,playerid,receiver,id);
    SendMessageToAdmins(COLOR_LIME,string);
   
    printf("ADMIN %s HAS BANNED %s FOR: %s", sender, receiver, reason);
   
    new INI:File = INI_Open(UserPath(id)); //added this as you told, changed to id
    INI_WriteString("Banned By", sender); //added this as you told ||error line
    INI_WriteString("Reason", reason); //added this as you told ||error line
    INI_Close(File); //added this as you told
   
    return 1;
}
But, i get this error:

Код:
test2.pwn(7459) : error 035: argument type mismatch (argument 1)
test2.pwn(7460) : error 035: argument type mismatch (argument 1)
EDIT:

This fixed it:

pawn Код:
new INI:File = INI_Open(UserPath(id));
    INI_WriteString(File,"Banned By", sender);
    INI_WriteString(File,"Reason", reason);
    INI_Close(File);
+Rep added for trying
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)