Getting last login -
Tanush123 - 02.02.2012
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:
Re: Getting last login -
Bogdan1992 - 02.02.2012
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);
Re: Getting last login -
Tanush123 - 02.02.2012
Its not a string, its a interger
Re: Getting last login -
IceCube! - 02.02.2012
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..
Re: Getting last login -
Lorenc_ - 02.02.2012
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
Re: Getting last login -
Tanush123 - 02.02.2012
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"
Re: Getting last login -
IceCube! - 02.02.2012
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)
Re: Getting last login -
Jefff - 02.02.2012
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
Re: Getting last login -
Tanush123 - 02.02.2012
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]