01.04.2014, 22:50
Hello how can I make with command to get offline data for example level and money. I use mysql R38. Thanks
CMD:ocheckplayer(playerid, params[])
{
new targetid;
if(sscanf(params,"i", targetid)) return SendClientMessage(playerid, REPLACE_WITH_COLOR, "Correct Usage: /ocheckplayer (offline name / id)");
// Do your query here to check if player exists in db
then echo out the data
}
CMD:offcheckdata(playerid,params[])
{
if(Logged[playerid] != 1)
{
SCM(playerid,COLOR_GRAD2,"{FFFFFF}[{F81414}G-Protect{FFFFFF}] {C3C3C3}Most be logged in!");
return 1;
}
if(PlayerInfo[playerid][Admin] >= 1337 || IsPlayerAdmin(playerid))
{
new name[128],query[128];
if(sscanf(params,"s[128]",name))
{
SCM(playerid,COLOR_GRAD2,"{FFAF00}Use: {FFFFFF}/offcheckdata [Player name]");
return 1;
}
if(IsPlayerConnected(ReturnUser(name))) return SCM(playerid,0xDB023EFF,"[!!!] That player is online!");
mysql_format(mysql,query,128,"SELECT * FROM `users` WHERE `Nick` = '%e'",name);
mysql_tquery(mysql,query,"Offcheck","i",playerid);// here is the public for data
}
else return SCM(playerid,COLOR_GRAD2,"{FFFFFF}[{F81414}G-Protect{FFFFFF}] {C3C3C3}Just admins!");
return 1;
}
forward Offcheck(playerid);
public Offcheck(playerid)
{
new rows,fields;
cache_get_data(rows,fields,mysql);
if(rows)
{
cache_get_field_content_int(0,"Level",Promenljive[playerid][0]);
cache_get_field_content_int(0,"Admin",Promenljive[playerid][1]);
cache_get_field_content_int(0,"GameMaster",Promenljive[playerid][2]);
SCMF(playerid,COLOR_ZUTA1,"Level[%d] AdminLV[%d] GSLevel[%d]",
Promenljive[playerid][0],Promenljive[playerid][1],Promenljive[playerid][2]); // and here it supose to show me that player offline lvl admin lvl and gamemaster lvl but instead everything was 0
}
return 1;
}
forward Offcheck(playerid);
public Offcheck(playerid)
{
if(cache_num_rows() > 0)
{
cache_get_field_content_int(0,"Level",Promenljive[playerid][0]);
cache_get_field_content_int(0,"Admin",Promenljive[playerid][1]);
cache_get_field_content_int(0,"GameMaster",Promenljive[playerid][2]);
SCMF(playerid,COLOR_ZUTA1,"Level[%d] AdminLV[%d] GSLevel[%d]",
Promenljive[playerid][0],Promenljive[playerid][1],Promenljive[playerid][2]);
}
return 1;
}
CMD:offcheckdata(playerid,params[])
{
if(Logged[playerid] != 1)
{
SCM(playerid,COLOR_GRAD2,"{FFFFFF}[{F81414}G-Protect{FFFFFF}] {C3C3C3}Most be logged in!");
return 1;
}
if(PlayerInfo[playerid][Admin] >= 1337 || IsPlayerAdmin(playerid))
{
new name[128],query[128];
if(sscanf(params,"s[128]",name))
{
SCM(playerid,COLOR_GRAD2,"{FFAF00}Use: {FFFFFF}/offcheckdata [Player name]");
return 1;
}
if(IsPlayerConnected(ReturnUser(name))) return SCM(playerid,0xDB023EFF,"[!!!] That player is online!");
mysql_format(mysql,query,128,"SELECT * FROM `users` WHERE `Nick` = '%e'",name);
mysql_tquery(mysql,query,"Offcheck","i",playerid);// here is the public for data
}
else return SCM(playerid,COLOR_GRAD2,"{FFFFFF}[{F81414}G-Protect{FFFFFF}] {C3C3C3}Just admins!");
return 1;
}
public Offcheck(playerid)
{
if(cache_num_rows() > 0)
{
cache_get_field_content_int(0,"Level",Promenljive[playerid][0]);
cache_get_field_content_int(0,"Admin",Promenljive[playerid][1]);
cache_get_field_content_int(0,"GameMaster",Promenljive[playerid][2]);
SCMF(playerid,COLOR_ZUTA1,"Level[%d] AdminLV[%d] GSLevel[%d]",
Promenljive[playerid][0],Promenljive[playerid][1],Promenljive[playerid][2]);
}
else if(cache_num_rows() = 0)
{
SendClientMessage(playerid, -1, "Notice: Account does not exist.");
}
return 1;
}