2 sscanf in same command ?
#1

How can i do this kind of a command .. for some reason the printf isn't called but the showsyntax is.


pawn Код:
CMD:aevent(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] < 3) return 1;
    new option[256];
    if(sscanf(params, "s[256]", option))
    {
        ShowSyntax(playerid, "/aevent <Option>");
        SCM(playerid, COLOR_SERVER, "Options: {FFFFFF}Heal, Armour, GiveGun, Disarm, Respawn,(Un)Freeze, Repair, Nos");
        return 1;
    }
        if(strcmp(option,"heal",true) == 0)
        {
                new amount;
        if(sscanf(params, "i", amount)) return ShowSyntax(playerid, "/aevent heal <Value>");
        printf("Chemat");
                foreach(new i : Player)
        {
            printf("intrat");
            if (FindNear(60.0, playerid, i))
            {

                SetPlayerHealth(i, amount);
                format(strglobal, sizeof(strglobal), "(Admin Event) {FFFFFF}%s set your health to %d.0", GetName(playerid), amount);
                SCM(i, COLOR_LIGHTRED, strglobal);
            }
        }
        }
    return 1;
}
Reply
#2

You can either use:
pawn Код:
if (!sscanf(params, "'heal'f", amount)
{
    // code..
}
but that will not ignore the case of the letters and neither will show the usage for heal option. Another way is this:
PHP код:
    if (isnull(params))
    {
        
ShowSyntax(playerid"/aevent <Option>");
        
SCM(playeridCOLOR_SERVER"Options: {FFFFFF}Heal, Armour, GiveGun, Disarm, Respawn,(Un)Freeze, Repair, Nos");
        return 
1;
    }
    if (!
strcmp(params"heal"true4))
    {
        new
            
Floatamount;
            
        if (
sscanf(params[4], "f"amount)) return print("/aevent heal <Value>");
        
        foreach(new 
Player)
        {
            if (
FindNear(60.0playeridi))
            {
                
SetPlayerHealth(iamount);
                
format(strglobalsizeof(strglobal), "(Admin Event) {FFFFFF}%s set your health to %.1f"GetName(playerid), amount);
                
SCM(iCOLOR_LIGHTREDstrglobal);
            }
        }
    }
    else if (!
strcmp(params"armour"true6))
    {
        new
            
Floatamount;
        if (
sscanf(params[6], "f"amount)) return print("/aevent armour <Value>");
        
        
// code..
    
}
    
// rest of them..
    
else
    {
        
ShowSyntax(playerid"/aevent <Option>");
        
SCM(playeridCOLOR_SERVER"Options: {FFFFFF}Heal, Armour, GiveGun, Disarm, Respawn,(Un)Freeze, Repair, Nos");
    } 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)