Ban account problem
#1

Hello, i made this command to offline ban a player account but doesn't work, it doesn't set Banned to 1

pawn Код:
CMD:banacc(playerid,params[])
{
    if(PlayerInfo[playerid][pAdmin] >= 5)
    {
    new name[MAX_PLAYER_NAME];
    new aName[MAX_PLAYER_NAME];
    new aid;
    new string[200];
    new echos[200];
    new am[128];
    new str[60];
    new Year, Month, Day, Hour, Minute, Second;
    getdate(Year, Month, Day);
    gettime(Hour, Minute, Second);
    GetPlayerName(aid, aName, sizeof(aName));
    if(sscanf(params, "s",name)) return SendClientMessage(playerid,-1,"{F70505}Usage: {FFFFFF}/banacc <account name>");
    if(!fexist(UserPath(playerid))) return SendClientMessage(playerid, red, "Player account not found, please note the files are CASE SENSITIVE.");
    else
    {
    new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,"data");
    INI_WriteInt(File,"Banned",1);
    INI_Close(File);
    }
   
    format(str,sizeof(str),"banip %s",PlayerInfo[playerid][pIp]);
    SendRconCommand(str);
   
    format(string, sizeof(string), "Admin %s (%d) banned %s's account - %02d/%02d/%d - %02d:%02d:%02d", aName,aid,name,Day,Month,Year,Hour,Minute,Second);
    format(echos, sizeof(echos), "1,4Admin %s (%d) banned %s's account - %02d/%02d/%d - %02d:%02d:%02d", aName,aid,name,Day,Month,Year,Hour,Minute,Second);
    format(am, sizeof(am), "You have successfully banned %s's account.", name);
    SendClientMessage(aid,red,am);
    SendMessageToAdmins(red,string);
    IRC_Say(gGroupID, IRC_CHANNEL, echos);
    IRC_Say(gGroupID, IRC_ACHANNEL, echos);
    AccBanLog(string);
    }
    return 1;
}
Reply
#2

pawn Код:
CMD:banacc(playerid,params[])
{
    if(PlayerInfo[playerid][pAdmin] > = 5)
    {
    new name[MAX_PLAYER_NAME];
    new aName[MAX_PLAYER_NAME];
    new aid;
    new string[200];
    new echos[200];
    new am[128];
    new str[60];
    new Year, Month, Day, Hour, Minute, Second;
    getdate(Year, Month, Day);
    gettime(Hour, Minute, Second);
    GetPlayerName(aid, aName, sizeof(aName));
    if(sscanf(params, "s",name)) return SendClientMessage(playerid,-1,"{F70505}Usage: {FFFFFF}/banacc <account name>");
    if(!fexist(UserPath(playerid))) return SendClientMessage(playerid, red, "Player account not found, please note the files are CASE SENSITIVE.");
    else
    {
    new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,"data");
    INI_WriteInt(File,"Banned",1);
    INI_Close(File);
    }
   
    format(str,sizeof(str),"banip %s",PlayerInfo[playerid][pIp]);
    SendRconCommand(str);
   
    format(string, sizeof(string), "Admin %s (%d) banned %s's account - %02d/%02d/%d - %02d:%02d:%02d", aName,aid,name,Day,Month,Year,Hour,Minute,Second);
    format(echos, sizeof(echos), "1,4Admin %s (%d) banned %s's account - %02d/%02d/%d - %02d:%02d:%02d", aName,aid,name,Day,Month,Year,Hour,Minute,Second);
    format(am, sizeof(am), "You have successfully banned %s's account.", name);
    SendClientMessage(aid,red,am);
    SendMessageToAdmins(red,string);
    IRC_Say(gGroupID, IRC_CHANNEL, echos);
    IRC_Say(gGroupID, IRC_ACHANNEL, echos);
    AccBanLog(string);
    }
    return 1;
}
Reply
#3

Uhm,

Epic fail?

PHP код:
if(!fexist(UserPath(playerid))) return SendClientMessage(playeridred"Player account not found, please note the files are CASE SENSITIVE."); 
It checks if the user's who are using the account file are exist NOT the player name that was putted in the parameters.
Reply
#4

Код:
CMD:banacc(playerid,params[])
{
    if(PlayerInfo[playerid][pAdmin] >= 5)
    {
    new name[MAX_PLAYER_NAME];
    new aName[MAX_PLAYER_NAME];
    new aid;
    new string[200];
    new echos[200];
    new am[128];
    new str[60];
    new Year, Month, Day, Hour, Minute, Second;
    getdate(Year, Month, Day);
    gettime(Hour, Minute, Second);
    GetPlayerName(aid, aName, sizeof(aName));
    if(sscanf(params, "s",name)) return SendClientMessage(playerid,-1,"{F70505}Usage: {FFFFFF}/banacc <account name>");
    if(!fexist(UserPath(aid))) return SendClientMessage(playerid, red, "Player account not found, please note the files are CASE SENSITIVE.");
    else
    {
    new INI:File = INI_Open(UserPath(aid));
    INI_SetTag(File,"data");
    INI_WriteInt(File,"Banned",1);
    INI_Close(File);
    }
    
    format(str,sizeof(str),"banip %s",PlayerInfo[aid][pIp]);
    SendRconCommand(str);
    
    format(string, sizeof(string), "Admin %s (%d) banned %s's account - %02d/%02d/%d - %02d:%02d:%02d", aName,aid,name,Day,Month,Year,Hour,Minute,Second);
    format(echos, sizeof(echos), "1,4Admin %s (%d) banned %s's account - %02d/%02d/%d - %02d:%02d:%02d", aName,aid,name,Day,Month,Year,Hour,Minute,Second);
    format(am, sizeof(am), "You have successfully banned %s's account.", name);
    SendClientMessage(aid,red,am);
    SendMessageToAdmins(red,string);
    IRC_Say(gGroupID, IRC_CHANNEL, echos);
    IRC_Say(gGroupID, IRC_ACHANNEL, echos);
    AccBanLog(string);
    }
    return 1;
}
Reply
#5

Quote:
Originally Posted by Romel
Посмотреть сообщение
Uhm,

Epic fail?

PHP код:
if(!fexist(UserPath(playerid))) return SendClientMessage(playeridred"Player account not found, please note the files are CASE SENSITIVE."); 
It checks if the user's who are using the account file are exist NOT the player name that was putted in the parameters.
I tried using name instead of playerid but nothing.

Red_John and James_Nick, doesn't work.
Reply
#6

of course you cannot use the string name in the code i mention.
Because name is string and UserPath needs the parameters to be integer not string.

You could try something like formatting the file path.
Reply
#7

Quote:
Originally Posted by Romel
Посмотреть сообщение
of course you cannot use the string name in the code i mention.
Because name is string and UserPath needs the parameters to be integer not string.

You could try something like formatting the file path.
Can you give me an example?
Reply
#8

I'm not sure since this topic gives me extremely high scripting skills...

PHP код:
format(stringsizeof(string), "Users/%s.ini"name); 
However that wouldn't work.
Reply
#9

create a var called (anything you want).
pawn Код:
new file[100];
Now:

pawn Код:
format(file, sizeof(file),"Users/%s.ini", name); //You have to define your user path
Now check
pawn Код:
if(!fexist(file)) //--------Your codes---------//
proper will be:

pawn Код:
new file[100];
format(file, sizeof(file),"Users/%s.ini", name); //You have to define your user path
if(!fexist(file)) //--------Your codes---------//
That should work.
Reply
#10

Romel thanks anyway but doesn't work.

Jarnu i tried in this way:

pawn Код:
new file[100];
    format(file, sizeof(file),"Users/%s.ini", name);
    if(!fexist(file))
    {
    INI_SetTag(file,"data");
    INI_WriteInt(file,"Banned",1);
    INI_Close(file);
    }
But...

(5194) : error 035: argument type mismatch (argument 1)
(5195) : error 035: argument type mismatch (argument 1)
(5196) : error 035: argument type mismatch (argument 1)

5194,5195,5196.

pawn Код:
INI_SetTag(file,"data");
    INI_WriteInt(file,"Banned",1);
    INI_Close(file);
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)