SA-MP Forums Archive
SSCANF Help! - 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: SSCANF Help! (/showthread.php?tid=310999)



SSCANF Help! - SuperChock - 14.01.2012

Hello, how I make a Gang Command using Sscanf? I tried this (but don't work correctly):

pawn Код:
YCMD:gang(playerid, params[], pHELPS)
{
    new gParams[10];
    if(sscanf(params, "s[10]", gParams))
    {
        SendClientMessage(playerid, 0xFFFFFFFF, "USE: /gang [create/invite]");
        return 1;
    }
    if(!strcmp(params, "create", true))
    {
        new gName[20];
        if(sscanf(gParams, "s[20]", gName))
        {
            SendClientMessage(playerid, 0xFFFFFFFF, "USE: /gang create [Name]");
            return 1;
        }
        SendPlayerMessage(playerid, 0xFFFFFFFF, "Created: %s", gName); // debug
        return 1;
    }
    return 1;
}
Help me please and sorry from my bad English


Re: SSCANF Help! - Lee_Percox - 14.01.2012

pawn Код:
YCMD:gang(playerid, params[], pHELPS)
{
    new gParams[10], gName[20];
    if(sscanf(params, "s[10] ", gParams))
    {
        SendClientMessage(playerid, 0xFFFFFFFF, "USE: /gang [create/invite]");
        return 1;
    }
    if(strcmp(params, "create", true))
    {
        if(sscanf(gParams, "s[10]s[20]", gParams, gName))
        {
            SendClientMessage(playerid, 0xFFFFFFFF, "USE: /gang create [Name]");
            return 1;
        }
        SendPlayerMessage(playerid, 0xFFFFFFFF, "Created: %s", gName); // debug
        return 1;
    }
    return 1;
}
Try this.


Re: SSCANF Help! - SuperChock - 14.01.2012

Thanks, but don't work


Re: SSCANF Help! - Lee_Percox - 14.01.2012

woops, you see this:

if(sscanf(gParams, "s[10]s[20]", gParams, gName))

Change that too

if(sscanf(params, "s[10]s[20]", gParams, gName))

Didn't notice that ;p


Re: SSCANF Help! - SuperChock - 14.01.2012

pawn Код:
YCMD:gang(playerid, params[], pHELPS)
{
    new gParams[10], gName[20];
    if(sscanf(params, "s[10] ", gParams))
    {
        SendClientMessage(playerid, 0xFFFFFFFF, "USE: /gang [create/invite]");
        return 1;
    }
    if(strcmp(params, "create", true))
    {
        if(sscanf(params, "s[10]s[20]", gParams, gName))
        {
            SendClientMessage(playerid, 0xFFFFFFFF, "USE: /gang create [Name]");
            return 1;
        }
        SendPlayerMessage(playerid, 0xFFFFFFFF, "Created: %s", gName); // debug
        PlayerPlaySound(playerid, 1057, 0.0, 0.0, 0.0); // debug
        return 1;
    }
    return 1;
}

The sscanf If run correctly, but the "debug" is not executed, the code crashes.


Re: SSCANF Help! - SuperChock - 14.01.2012

Help me please