SA-MP Forums Archive
Need help - sscanf - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Need help - sscanf (/showthread.php?tid=659208)



Need help - sscanf - Score - 27.09.2018

Hello, how can i make so a player can use /stats to view their own stats, or someone else's stats by doing /stats [targetid]

EX: if he does /stats, this will show up:

PHP код:
SendClientMessageEx(playeridCOLOR_GREY"User Statistics for {665353}%s(%d) {AFAFAF}- Database ID: {665353}%d"GetName(playerid), playeridPlayerInfo[playerid][ID]); 
If he does /stats [targetid], something like this:

PHP код:
Target's stats here 



Re: Need help - sscanf - m4karow - 27.09.2018

set the targetid default value to -1. whenever its equal to -1 you check for your own stats, else you check for others
sscanf(params, “R(-1)”); maybe


Re: Need help - sscanf - Score - 27.09.2018

Quote:
Originally Posted by m4karow
Посмотреть сообщение
set the targetid default value to -1. whenever its equal to -1 you check for your own stats, else you check for others
And how do i do that?


Re: Need help - sscanf - AlfaSufaIndo - 27.09.2018

Quote:
Originally Posted by Score
Посмотреть сообщение
Hello, how can i make so a player can use /stats to view their own stats, or someone else's stats by doing /stats [targetid]

EX: if he does /stats, this will show up:

PHP код:
SendClientMessageEx(playeridCOLOR_GREY"User Statistics for {665353}%s(%d) {AFAFAF}- Database ID: {665353}%d"GetName(playerid), playeridPlayerInfo[playerid][ID]); 
If he does /stats [targetid], something like this:

PHP код:
Target's stats here 
maybe this code can help you
PHP код:
new idstring[64];
if(
sscanf(params"u"id))
{
    
// FOR TARGET ID
    
return 1;
}
else
{
    
//FOR YOURSELF




Re: Need help - sscanf - Score - 27.09.2018

Quote:
Originally Posted by AlfaSufaIndo
Посмотреть сообщение
maybe this code can help you
PHP код:
new idstring[64];
if(
sscanf(params"u"id))
{
    
// FOR TARGET ID
    
return 1;
}
else
{
    
//FOR YOURSELF

No it won't, you didn't even understand me.


Re: Need help - sscanf - AlfaSufaIndo - 27.09.2018

or Maybe like this? CMIIW.
If you only type /stats. it will show your stats
If you type /stats [giveplayerid] you will see giveplayerid stats

PHP код:
CMD:stats(playeridparams[])
{
    if(
PlayerInfo[playerid][pAdmin] > 11)
    {
        new 
giveplayeridstring[64];
        if(
sscanf(params"u"giveplayerid))
        {
            
SendClientMessageEx(playeridCOLOR_GREY"User Statistics for {665353}%s(%d) {AFAFAF}- Database ID: {665353}%d"GetName(playerid), playeridPlayerInfo[playerid][ID]);
            return 
1;
        }
        else
        {
            
SendClientMessageEx(playeridCOLOR_GREY"User Statistics for {665353}%s(%d) {AFAFAF}- Database ID: {665353}%d"GetName(giveplayerid), PlayerInfo[giveplayerid][ID], PlayerInfo[giveplayerid][ID]);
        }
    }
    else
    {
        
SendClientMessageEx(playeridCOLOR_GRAD1"{A9A9A9}ERROR: You don't have permission to use command.");
        return 
1;
    }
    return 
1;