SSCANF Question
#1

How do I made like a CMD for example, and when I type ID it will show to someone else the drugs, and when I don't type ID it will show the drugs to me.


pawn Код:
CMD:mydrugs(playerid, params[])
{
    new id;
    if(!sscanf(params,"U(-1)#playerid", id))
    {
        ShowPlayerDrugs(playerid, id);
    }
    return 1;
}
It isn't working
Reply
#2

try
pawn Код:
if(!sscanf(params,"U("#playerid")", id))
Reply
#3

I might be wrong, but I think that will just insert the literal string "playerid" rather than formatting the actual number. So, you can either format the format ( ) before passing it to sscanf. Or you can check if the playerid is -1 after sscanf is done processing.
Reply
#4

pawn Код:
CMD:mydrugs(playerid, params[])
{
    new id;
    if(isnull(params))
    {
        ShowPlayerDrugs(playerid, playerid) // like this perhaps?
    }
    else
    {
        if(!sscanf(params,"u", id))
        {
            if(id != INVALID_PLAYER_ID) ShowPlayerDrugs(playerid, id);         
        }
    }
    return 1;
}
Not sure I understood what you meant, but this could be one way I guess?
Reply
#5

Yes, thank you man.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)