problems with this 2 cmds
#1

Ok i got a problem with this 2 cmds, i spent like 20 minutes without finding nothing that can "disturb" the cmd.

The first is /banacc, it works good with a problem:

Quote:

** Admin (0) banned chucky_jax's account - 05/04/2013 - 01:42:23

It doesn't show admin name and is always id 0. Code:

pawn Код:
CMD:banacc(playerid,params[])
{
    if(pInfo[playerid][Logged] == 0) return SCM(playerid,0x0080C0FF,"Please login before using this command.");
    if(pInfo[playerid][Admin] >= 5)
    {
    new id;
    new name[128];
    new aName[MAX_PLAYER_NAME];
    GetPlayerName(id, aName, sizeof(aName));
    if(sscanf(params, "s[128]",name)) return SCM(playerid,-1,"{F70505}Usage: {FFFFFF}/banacc <account name>");
    if(GetPVarInt(id,"CmdTime")>GetTickCount())return SCM(playerid,0xFF0000FF,"Please wait before using this command again.");
    new string[250];
    new echos[250];
    new Year, Month, Day, Hour, Minute, Second;
    getdate(Year, Month, Day);
    gettime(Hour, Minute, Second);

    new stringo[90];
    new filestring[128];
    format(filestring, sizeof(filestring), "/Users/%s.ini", name);
    if(!fexist(filestring)) return SCM(playerid,red, "Player account not found.");
    else
    {
        new INI:File = INI_Open(filestring);
        INI_SetTag(File, "Player's Data");
        INI_WriteInt(File, "Banned",1);
        INI_Close(File);
        format(stringo, sizeof(stringo),"Success! You have banned %s", name);
        SCM(playerid, red,stringo);
    }
    format(string, sizeof(string), "** Admin %s (%d) banned %s's account - %02d/%02d/%02d - %02d:%02d:%02d", aName,id,name,Day,Month,Year,Hour,Minute,Second);
    format(echos, sizeof(echos), "1,4** Admin %s (%d) banned %s's account - %02d/%02d/%02d - %02d:%02d:%02d", aName,id,name,Day,Month,Year,Hour,Minute,Second);
    SendMessageToAdmins(red,string);
    IRC_Say(gGroupID, IRC_CHANNEL, echos);
    IRC_Say(gGroupID, IRC_ACHANNEL, echos);
    SetPVarInt(id,"CmdTime",GetTickCount()+2000);
    AccBanLog(string);
    }
    return 1;
}
2nd is more complex, in addition with no name and id 0, it CRASHES the server after i execute the commands (but the account is unbanned)

pawn Код:
CMD:unbanacc(playerid,params[])
{
    if(pInfo[playerid][Logged] == 0) return SCM(playerid,0x0080C0FF,"Please login before using this command.");
    if(pInfo[playerid][Admin] >= 5)
    {
    new aid;
    if(GetPVarInt(aid,"CmdTime")>GetTickCount())return SCM(playerid,0xFF0000FF,"Please wait before using this command again.");
    new name;
    new string[200];
    new echos[200];
    new Year, Month, Day, Hour, Minute, Second;
    getdate(Year, Month, Day);
    gettime(Hour, Minute, Second);
    new aName[MAX_PLAYER_NAME];
    GetPlayerName(aid, aName, sizeof(aName));
    if(sscanf(params, "s[128]",name)) return SCM(playerid,-1,"{F70505}Usage: {FFFFFF}/unbanacc <account name>");

    new stringo[90];
    new filestring[128];
    format(filestring, sizeof(filestring), "/Users/%s.ini", name);
    if(!fexist(filestring)) return SCM(playerid,red, "Player account not found.");
    else
    {
        new INI:File = INI_Open(filestring);
        INI_SetTag(File, "Player's Data");
        INI_WriteInt(File, "Banned",0);
        INI_Close(File);
        format(stringo, sizeof(stringo),"Success! You have unbanned %s", name);
        SCM(playerid, red,stringo);
    }
   
    format(string, sizeof(string), "** Admin %s (%d) unbanned %s's account - %02d/%02d/%02d - %02d:%02d:%02d", aName,aid,name,Day,Month,Year,Hour,Minute,Second);
    format(echos, sizeof(echos), "1,4** Admin %s (%d) unbanned %s's account - %02d/%02d/%02d - %02d:%02d:%02d", aName,aid,name,Day,Month,Year,Hour,Minute,Second);
    SendMessageToAdmins(red,string);
    IRC_Say(gGroupID, IRC_CHANNEL, echos);
    IRC_Say(gGroupID, IRC_ACHANNEL, echos);
    SetPVarInt(aid,"CmdTime",GetTickCount()+2000);
    UnBanLog(string);
    }
    return 1;
}
Thanks for help guys.
Reply
#2

Try changing it to
pawn Код:
GetPlayerName(playerid, aName, sizeof(aName));
edit: The first piece of code, that is.
Reply
#3

Quote:
Originally Posted by BigGroter
Посмотреть сообщение
Try changing it to
pawn Код:
GetPlayerName(playerid, aName, sizeof(aName));
edit: The first piece of code, that is.
Damn im really a noob, thanks. What about /unban cmd?
Reply
#4

No problem! And same thing here for the name.
pawn Код:
GetPlayerName(playerid, aName, sizeof(aName));
As for the crashing issue, I do not know. I will have a look at it later.
Reply
#5

Quote:
Originally Posted by BigGroter
Посмотреть сообщение
No problem! And same thing here for the name.
pawn Код:
GetPlayerName(playerid, aName, sizeof(aName));
As for the crashing issue, I do not know. I will have a look at it later.
I thought the crash issue was releated to the account unban log file but i have it..
Reply
#6

Great.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)