Some some "INI_WriteInt" questions
#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


Messages In This Thread
Some some "INI_WriteInt" questions - by Kyance - 26.01.2014, 13:14
Re: Some some "INI_WriteInt" questions - by Sawalha - 26.01.2014, 13:23
Re: Some some "INI_WriteInt" questions - by Kyance - 26.01.2014, 13:34
Re: Some some "INI_WriteInt" questions - by Sawalha - 26.01.2014, 14:39
Re: Some some "INI_WriteInt" questions - by Kyance - 26.01.2014, 15:09

Forum Jump:


Users browsing this thread: 1 Guest(s)