Getting last login
#1

Well i think i failed, i was trying to make a /getlastlogin command for organization leaders so that will show when was the last time the person was connected. It updates my mysql so i got no problem with mysql, i only got problem with this
pawn Код:
CMD:getlastlogin(playerid,params[])
{
    new pyear,pmonth;
    if(PlayerData[playerid][Leader] == 0) return SCM(playerid,red,"ERROR: You are not an organization leader or co leader");
    if(sscanf(params,"s[24]",pname)) return SCM(playerid,grey,"USAGE: /getlastlogin [Player Name]");
    CheckMySQL();
    format(str,sizeof(str),"SELECT * FROM accounts WHERE Name = '%s'",pname);
    mysql_query(str);
    mysql_store_result();
    if(mysql_num_rows() != 0)
    {
        format(str,sizeof(str),"SELECT Year = %d,Month = %d WHERE Name '%s'",pyear,pmonth,pname);
        mysql_query(str);
        format(str,sizeof(str),"Name: {FF9900}%s",pname);
        SCM(playerid,-1,str);
        format(str,sizeof(str),"Date: {FF9900}%d %d",pmonth,pyear);
        SCM(playerid,-1,str);
    }
    else
    {
        SCM(playerid,red,"ERROR: That name is not available");
    }
    return 1;
}
it shows 0 0 for Date:
Reply
#2

Use %s, i know its wired but it works for me.

format(str,sizeof(str),"Date: {FF9900}%s %s",pmonth,pyear);
SCM(playerid,-1,str);
Reply
#3

Its not a string, its a interger
Reply
#4

Now I cant see you using gatdate();

Or what ever the function is called. If this is global remove your intergers inside the command or it if its not global use the function.

^^ Dont hold me to this..
Reply
#5

Why create 3 columns when you can just insert all data in one then use sscanf to obtain the values from the string.

Use getdate, then make a varchar column about 13 characters and store the crap inside there. After whilst in a loading function to retrieve all statistics of the player, simply just obtain that columns data and insert into a string.

pawn Код:
new day, month, year;
sscanf( szPlayerDate, "ddd", day, month, year );
Hope you get a idea
Reply
#6

well i fixed it and btw how can i make if the name the player entered has the same digit for PlayerData[playerid][Member] like the playerid, it will work or else it will show "That person is not in your organization"
Reply
#7

Quote:
Originally Posted by Lorenc_
Посмотреть сообщение
Why create 3 columns when you can just insert all data in one then use sscanf to obtain the values from the string.

Use getdate, then make a varchar column about 13 characters and store the crap inside there. After whilst in a loading function to retrieve all statistics of the player, simply just obtain that columns data and insert into a string.

pawn Код:
new day, month, year;
sscanf( szPlayerDate, "ddd", day, month, year );
Hope you get a idea
I have never though of this and I like making little edits like this to my code. I'm going to have a little try with it now, Thanks +REP (Sorry for stealing this thread you can have it back now :P)
Reply
#8

pawn Код:
CMD:getlastlogin(playerid,params[])
{
    if(!PlayerData[playerid][Leader]) SCM(playerid,red,"ERROR: You are not an organization leader or co leader");
    else if(!(3 <= strlen(params) <= 24)) SCM(playerid,grey,"USAGE: /getlastlogin [Player Name]");
    else{
        CheckMySQL();
        format(str,sizeof(str),"SELECT `Year`,`Month` FROM accounts WHERE Name = '%s' LIMIT 1;",params);
        mysql_query(str);
        mysql_store_result();
        if(mysql_num_rows())
        {
            new pyear[5],pmonth[3];
            mysql_fetch_field_row(pyear,"Year");
            mysql_fetch_field_row(pmonth,"Month");
            mysql_free_result();
            format(str,sizeof(str),"Name: {FF9900}%s",params);
            SCM(playerid,-1,str);
            format(str,sizeof(str),"Date: {FF9900}%s %s",pmonth,pyear);
            SCM(playerid,-1,str);
        }
        else
        {
            mysql_free_result();
            SCM(playerid,red,"ERROR: That name is not available");
        }
    }
    return 1;
}
but why 3 colums, use timestamp
Reply
#9

I just need help to see if the playerid PlayerData[playerid][Member] is the same as the name that is entered in /getlastlogin PlayerData[otherperson][Member]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)