SSCANF error 035: argument type mismatch (argument 2)
#7

Quote:
Originally Posted by Mean
Посмотреть сообщение
+ 1, SSCANF doesn't make much use if you use STRCMP, you should either use ZCMD or YCMD.
actually this is true. sscanf does not really make much sense without zcmd, or ycmd. Its possible to get it to work, but its ugly
[edit]
Quote:
Originally Posted by PowerPC603
Посмотреть сообщение
Also an error:
Should be:
pawn Код:
new text[128], string[70], pName[MAX_PLAYER_NAME];
    if(sscanf(cmdtext, "s[128]",text)) return SendClientMessage(playerid,COLOR_ERROR,"Usage: /o [Msg]"); // line with error
You are also wrong, why would you assume that the OP is using the plugin version of sscanf without mentioning this in your reply. Also, why would you suggest extracting a string length of 128 to be formatted into a string of size 70?

using sscanf to extract a single parameter kind of defeats the purpose.

finally, cmdtext will include the /o command ( in this example ) so this is what sscanf will extract, not the text following.

so all you really need is something like this...
pawn Код:
if(!strcmp(cmdtext,"/o",true,2))
{
     if(strlen(cmdtext) < 4) return SendClientMessage(playerid,COLOR_COLOR,"USAGE: /o [text]");
     strdel(cmdtext,0,3);
     new
          string[128],
          pName[MAX_PLAYER_NAME]
     ;
     GetPlayerName(playerid,pName,sizeof(pName));
     format(string,sizeof(string),"(( %s : %s ))",pName,cmdtext);
     SendClientMessageToAll(COLOR_COLOR,string);
     return 1;
}
having said this, it still isn't perfect because adding this to your script will preclude you from having any other commands starting with /o, so you would kind of have to use strtok.
This brings us back to the reason why using zcmd is so much easier
pawn Код:
CMD:o(playerid,params[])
{
     if(isnull(params)) return SendClientMessage(playerid,COLOR_COLOR,"USAGE: /o [text]");
     new
          string[128],
          pName[MAX_PLAYER_NAME]
     ;
     GetPlayerName(playerid,pName,sizeof(pName));
     format(string,sizeof(string),"(( %s : %s ))",pName,params);
     SendClientMessageToAll(COLOR_COLOR,string);
     return 1;
}
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 2 Guest(s)