Banning offline player
#1

Alright so, I have this code but it wont work. It reads the data well, and yes you can only ban the player that has a actual account (works) but the problem is that it doesnt write the Banned and the player doesnt get banned at all.
It says it bans him but it doesnt. Maybe I screwed something up.
pawn Код:
CMD:banofflineplayer(playerid, params[])
{
    new targetname[24], filestring[79];
    if(PlayerInfo[playerid][pAdminLevel] >= 5)
    {
        if(sscanf(params, "s[24]", targetname)) return SendClientMessage(playerid, -1, "Correct Usage: /banofflineplayer [Player's Name]");
        format(filestring, sizeof(filestring), "/Users/%s.ini", targetname);
        if(!fexist(filestring)) return SendClientMessage(playerid, -1, "Error: The player name you have chosen was not found in our system.");
        else
        {
            new INI:file = INI_Open(Path(playerid));
            INI_SetTag(file, "Player's Data");
            INI_WriteInt(file, "Banned", 1);
            INI_Close(file);
            new done[128];
            format(done, sizeof(done), "You have banned %s", targetname);
            SendClientMessage(playerid,-1 , done);
        }
    }
    return 1;
}
#define UserPath "Users/%s.ini"


forward loadaccount_user(playerid, name[], value[]);
public loadaccount_user(playerid, name[], value[])
{
    INI_String("Password", PlayerInfo[playerid][pPass],129);
    INI_Int("AdminLevel",PlayerInfo[playerid][pAdminLevel]);
    INI_Int("VIPLevel",PlayerInfo[playerid][pVIPlevel]);
    INI_Int("Money",PlayerInfo[playerid][pMoney]);
    INI_Int("Scores",PlayerInfo[playerid][pScores]);
    INI_Int("Kills",PlayerInfo[playerid][pKills]);
    INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
    INI_Int("Kicks",PlayerInfo[playerid][pKicks]);
    INI_Int("Warns",PlayerInfo[playerid][pWarns]);
    INI_Int("Banned",PlayerInfo[playerid][pBanned]);
    return 1;
}


Etc...
My overal save and load works, but when I ban them using this it wont work. Help please?
Reply
#2

Look here....

new INI:file = INI_Open(Path(playerid));

This needs to be.....

new INI:file = INI_Open(xxx)

You need the file of the targetname... this looks like it's banning yourself!
Reply
#3

Ohhhh lmfao. Thanks, i'll try it now

Код:
error 035: argument type mismatch (argument 1)
Reply
#4

pawn Код:
new INI:file = INI_Open(Path(playerid));
You're banning yourself...

Change 'Path(playerid)' to 'filestring'.
Reply
#5

No problem... It won't be targetname specifically you'll need to construct the file path string based on targetname I don't have your Path() stock so I have no idea what that would be beyond assumptions.
Reply
#6

Quote:
Originally Posted by [uL]Pottus
Посмотреть сообщение
No problem... It won't be targetname specifically you'll need to construct the file path string based on targetname I don't have your Path() stock so I have no idea what that would be beyond assumptions.
Hmmm well I dont have any stock for it, just this
#define UserPath "Users/%s.ini"


EDIT: My bad!
Код:
stock Path(playerid)
{
    new str[128],name[MAX_PLAYER_NAME];
    GetPlayerName(playerid,name,sizeof(name));
    format(str,sizeof(str),UserPath,name);
    return str;
}
I still dont understand how to do it.

With this:
Код:
CMD:banofflineplayer(playerid, params[])
{
    new targetname[24], filestring[79];
    if(PlayerInfo[playerid][pAdminLevel] >= 5)
    {
	    if(sscanf(params, "s[24]", targetname)) return SendClientMessage(playerid, -1, "Correct Usage: /banofflineplayer [Player's Name]");
	    format(filestring, sizeof(filestring), "Users/%s.ini", targetname);
	    if(!fexist(filestring)) return SendClientMessage(playerid, -1, "Error: The player name you have chosen was not found in our system.");
	    else
	    {
	        new INI:file = INI_Open(Path(targetname));
	        INI_SetTag(file, "Player's Data");
	        INI_WriteInt(file, "Banned", 1);
	        INI_Close(file);
	        new done[128];
	        format(done, sizeof(done), "You have banned %s", targetname);
	        SendClientMessage(playerid,-1 , done);
	    }
	}
    return 1;
}
I get
Код:
argument type mismatch (argument 1)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)