Issue with SScanf and string
#1

Hello.
I have an issue with sscanf and storing a note in a enum.
this is my code
PHP код:
/* ============================================================================ */
COMMAND:barrier(playeridparams[])
{
    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 
tmp15 ], tmp215 ],tmp3[200];
    if(
sscanf(params"szzz"tmptmp2,tmp3))
        {
            
SendClientUsage(playerid,"/barrier [ Deploy / Destroy / List]");
        }
    else if(!
strcmp(tmp"deploy"true5))
        {
            new 
type;
             if(!
strlen(tmp2)) return SendClientUsage(playerid"/barrier deploy [1/2/3/4] [Note]");
             new 
barriertype strval(tmp2);
             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 
1MAX_BARRIERSi++)
                {
                    if(!
Barrier[i][bActive]) 
                        {
                            new 
Float:XFloat:YFloat:ZFloat:A;
                            new 
string[400];
                            
GetPlayerPos(playeridXYZ);
                            
GetPlayerFacingAngle(playeridA);
                            
Barrier[i][bObject] = CreateDynamicObject(typeXYZ0.00.0AGetPlayerVirtualWorld(playerid), GetPlayerInterior(playerid));
                            
Barrier[i][bLabel] = Create3DTextLabel(sprintf("Barrier ID %i",i),-1,X,Y,Z,10,GetPlayerVirtualWorld(playerid),0);
                            
Barrier[i][bActive] = 1;
                            
format(string,sizeof(string),"%s",tmp3);
                            
myStrcpy(Barrier[i][Note],string);
                            
SetPlayerPos(playeridX-1YZ+2);
                            
SendClientMessage(playerid,-1,sprintf("Barrier ID %i has been deployed",i));
                            break;
                        }
                }
            }
    else if(!
strcmp(tmp"destroy"true5))
        {
            new 
bid strval(tmp2);
            if(
bid || 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"true5))
    {
        for(new 
1MAX_BARRIERSi++)
            {
                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;
}
/* ============================================================================= */ 
So, Barrier[i][Note] only stores the first word, instead of the whole string.
What's the problem and how to fix it?
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)