Command problem
#1

Well for some reason when i use /agetlastlogin, every name i type has the same time as me. /agetlastlogin tells me when was the last time that person logged in
pawn Код:
CMD:agetlastlogin(playerid,params[])
{
    if(PlayerData[playerid][AdminLevel] < 2) return 0;
    if(sscanf(params,"s[24]",agetlast)) return SCM(playerid,grey,"USAGE: /getlastlogin [Player Name]");
    CheckMySQL();
    format(str,sizeof(str),"SELECT * FROM accounts WHERE Name = '%s'",agetlast);
    mysql_query(str);
    mysql_store_result();
    if(mysql_num_rows() != 0)
    {
        format(str,sizeof(str),"Name: {FF9900}%s",agetlast);
        SCM(playerid,-1,str);
        format(str,sizeof(str),"Date: {FF9900}%s %d %d",Months[strval(field[42]) - 1],strval(field[43]),strval(field[41]));
        SCM(playerid,-1,str);
        format(str,sizeof(str),"Time: {FF9900}%d:%d",strval(field[44]),strval(field[45]));
        SCM(playerid,-1,str);
    }
    else
    {
        SCM(playerid,red,"ERROR: That account does not exist.");
    }
    mysql_free_result();
    return 1;
}
Reply
#2

bump
Reply
#3

Where is agetlast variable declared?
Reply
#4

One question, which I ain't sure about:

Is the "return 1;" really neccessary, if "else" is false? I mean, try to delete it and look what will happen then...
Reply
#5

else is
pawn Код:
if(mysql_num_rows() == 0)
and agetlast is in the top of my gamemode
pawn Код:
new agetlast[24];
Reply
#6

Test it when a player connects AFTER you and see what happens.
Reply
#7

pawn Код:
CMD:agetlastlogin(playerid,params[])
{
    if(PlayerData[playerid][AdminLevel] < 2) return 0;
    if(sscanf(params,"s[24]",agetlast)) return SCM(playerid,grey,"USAGE: /getlastlogin [Player Name]");
    CheckMySQL();
    format(str,sizeof(str),"SELECT * FROM accounts WHERE Name = '%s'",agetlast);
    mysql_query(str);
    mysql_store_result();
    if(mysql_num_rows() != 0)
    {
        mysql_fetch_row_format(row, "|");//You forgot to fetch the row...
        explode(row,field, "|");//...and explode it.
        format(str,sizeof(str),"Name: {FF9900}%s",agetlast);
        SCM(playerid,-1,str);
        format(str,sizeof(str),"Date: {FF9900}%s %d %d",Months[strval(field[42]) - 1],strval(field[43]),strval(field[41]));
        SCM(playerid,-1,str);
        format(str,sizeof(str),"Time: {FF9900}%d:%d",strval(field[44]),strval(field[45]));
        SCM(playerid,-1,str);
    }
    else
    {
        SCM(playerid,red,"ERROR: That account does not exist.");
    }
    mysql_free_result();
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)