Issue with SScanf and string
#6

Quote:
Originally Posted by justjamie
Посмотреть сообщение
doesnt work
If you don't help us we can't help you! I barely could realize what you're trying to achieve.

pawn Код:
/* ============================================================================ */
COMMAND:barrier(playerid, params[])
{
    if(!Player[playerid][Authed]) return SendClientError(playerid, "You are not authed!");
    if(!IsFed(playerid)) return SendClientError(playerid,"You are not authorized to use this command!");
    new tmp[ 15 ], tmp2[ 64 ], barriertype;
    if(sscanf(params, "s[15]DS[64]", tmp, barriertype, tmp2))
        {
            SendClientUsage(playerid,"/barrier [ Deploy / Destroy / List]");
                    return 1;
        }
    else if(!strcmp(tmp, "deploy", true, 5))
        {  
             if(sscanf(params, "s[15]ds[64]", tmp, barriertype, tmp2)) return SendClientUsage(playerid, "/barrier deploy [1/2/3/4] [Note]");
 
             if(barriertype == 1)
                 {
                 type=978;
                 }
             else if(barriertype == 2)
                 {
                 type=978;
                 }
             else if(barriertype == 3)
                 {
                 type=978;
                 }
            else if(barriertype == 4)
                {
                type=978;
                }
            else
                {
                return SendClientUsage(playerid, "/barrier deploy [1/2/3/4] [Note]");
                }
            for(new i = 1; i < MAX_BARRIERS; i++)
                {
                    if(!Barrier[i][bActive])  
                        {
                            new Float:X, Float:Y, Float:Z, Float:A;
                            GetPlayerPos(playerid, X, Y, Z);
                            GetPlayerFacingAngle(playerid, A);
                            Barrier[i][bObject] = CreateDynamicObject(type, X, Y, Z, 0.0, 0.0, A, GetPlayerVirtualWorld(playerid), GetPlayerInterior(playerid));
                            Barrier[i][bLabel] = Create3DTextLabel(sprintf("Barrier ID %i",i),-1,X,Y,Z,10,GetPlayerVirtualWorld(playerid),0);
                            Barrier[i][bActive] = 1;
                            myStrcpy(Barrier[i][Note],tmp2);
                            SetPlayerPos(playerid, X-1, Y, Z+2);
                            SendClientMessage(playerid,-1,sprintf("Barrier ID %i has been deployed",i));
                            break;
                        }
                }
            }
    else if(!strcmp(tmp, "destroy", true, 5))
        {
            if(sscanf(params, "s[15]dS[64]", tmp, barriertype, tmp2)) return SendClientUsage(playerid, "/barrier destroy [id]");
            new bid = barriertype;
            if(bid < 1 || bid > MAX_BARRIERS) return SendClientError(playerid,"Invalid barrier id.");
            if(!Barrier[bid][bActive]) return SendClientError(playerid,"That barrier isn't deployed.");
            DestroyDynamicObject(Barrier[bid][bObject]);
            Delete3DTextLabel(Barrier[bid][bLabel]);
            Barrier[bid][bActive] = 0;
            SendClientMessage(playerid,-1,sprintf("Barrier ID %i has been destroyed.",bid));
        }
    else if(!strcmp(tmp, "list", true, 5))
    {
        for(new i = 1; i < MAX_BARRIERS; i++)
            {
                if(Barrier[i][bActive])  
                    {
                        SendClientMessage(playerid,-1,sprintf("Barrier ID %i | Note: %s",i,Barrier[i][Note]));
                    }
            }
    }
    else
        {
            SendClientUsage(playerid,"/barrier [ Deploy / Destroy / List]");
        }
    return 1;
}
/* ============================================================================= */
Not tested.
Reply


Messages In This Thread
Issue with SScanf and string - by justjamie - 26.08.2016, 14:23
Re: Issue with SScanf and string - by Marricio - 26.08.2016, 14:36
Re: Issue with SScanf and string - by DarkSkull - 26.08.2016, 14:37
Re: Issue with SScanf and string - by justjamie - 26.08.2016, 15:03
Re: Issue with SScanf and string - by Shinja - 26.08.2016, 15:06
Re: Issue with SScanf and string - by Marricio - 26.08.2016, 15:13
Re: Issue with SScanf and string - by justjamie - 26.08.2016, 15:16
Re: Issue with SScanf and string - by WhiteGhost - 26.08.2016, 15:18
Re: Issue with SScanf and string - by Stinged - 26.08.2016, 15:34
Re: Issue with SScanf and string - by Marricio - 26.08.2016, 19:13

Forum Jump:


Users browsing this thread: 1 Guest(s)