Little Confusion
#1

Hi,

Just wondering if you could help me.

I've got some code I started working on earlier and I came across something which stumped me.

pawn Код:
dcmd_addorg(playerid, params[])
{
     new iD, oName[128];
     if(sscanf(params, "is", iD, oName)) return SendClientMessage(playerid, COLOR_RED, "~ Incorrect Usage: /addorg [orgid] [orgname]);
     {
          //bla
     }
     return 1;
}
However if I went ingame, and did /addorg 1 San Andreas Police Department
it wouldn't work because ive got spaces between the San Andreas Police Department how can I make it so I can have spaces in the org name?
Reply
#2

I dont use sscanf to much but I've realised something.
pawn Код:
if(sscanf(params, "is", iD, oName)) return SendClientMessage(playerid, COLOR_RED, "~ Incorrect Usage: /addorg [orgid] [orgname]);

// has to be

if(sscanf(params, "
is[128]", iD, oName)) return SendClientMessage(playerid, COLOR_RED, "~ Incorrect Usage: /addorg [orgid] [orgname]);
Reply
#3

No it doesn't.
Reply
#4

Quote:
Originally Posted by iRemix
Посмотреть сообщение
No it doesn't.
wait, i think your right, nvm, sorry.
Reply
#5

The plugin version of sscanf does need the array sizes declared. And as far as I know, a string with spaces should work if it is the last param.
Reply
#6

pawn Код:
dcmd_addorg(playerid, params[])
{
     new iD;
     if(sscanf(params, "is", iD, params)) return SendClientMessage(playerid, COLOR_RED, "~ Incorrect Usage: /addorg [orgid] [orgname]");
     {
          //bla
     }
     return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)