[HELP] getting offline player data
#1

Hello how can I make with command to get offline data for example level and money. I use mysql R38. Thanks
Reply
#2

simple make a query to query the database for the given user id.

First if you are using a mysql database, the first thing you should have for player data is a column called ID. The reason for this is because a player could change his name and anything related to that name would be messed up. So instead we use a solid ID (In other words the value ID contains, never changes).

So you would make a command like this:

The example is using ZCMD:
pawn Код:
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
}
Hope this makes sense, if you need a more detailed tutorial then try using the search function on forums.
Reply
#3

I was searching for that kind of stuff but I didn't find I mean yesterday I was make that and when I was checking offline player data in mysql log says that is all datta here lvl admin lvl but it doesn't show to me. I mean it show me lvl 0 admlvl 0 and gamemaster lvl 0. Here's the code


pawn Код:
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;
}

pawn Код:
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;
}
Reply
#4

pawn Код:
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;
}
Try this. Althought, I wouldn't use numbers for player variables. I'd just use a name like "Admin", "Level" etc.
Reply
#5

How can I in command offcheckdata get when I type offcheckdata Luca_Marcus and then if that acc doesnt exist it send meesage like the account Luca_Marcus doens't exist in our database. Thanks
Reply
#6

pawn Код:
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;
}
Reply
#7

in command? thanks beacuse of name
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)