SA-MP Forums Archive
Command problem - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Command problem (/showthread.php?tid=316685)



Command problem - Tanush123 - 08.02.2012

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;
}



Re: Command problem - Tanush123 - 10.02.2012

bump


Re: Command problem - Nonameman - 10.02.2012

Where is agetlast variable declared?


Re: Command problem - Twisted_Insane - 10.02.2012

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...


Re: Command problem - Tanush123 - 11.02.2012

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



Re: Command problem - Tee - 11.02.2012

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


Re: Command problem - Tee - 11.02.2012

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;
}