Big "strtok" error/bug.
#6

Quote:
Originally Posted by Kwarde
Посмотреть сообщение
Ehm here's a small, little command, used with dcmd. It's an /me command.

pawn Код:
dcmd_me(playerid, params[])
{
    new Action[100]; //Used for the param. Important!
    new str[128], pName[MAX_PLAYER_NAME];
    if(sscanf(params, "s", action)) return 0; //No param used.
    GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
    format(str, 128, "%s %s", pName, Action);
    SendClientMessageToAll(0xFFFFFFAA, str);
    return 1;
}
When you use 'if(sscanf' stuff, it will show you when there is NO param filled in. The 's' is the string. It's the same with formatting: '%s'. So 'd', 'i' or 'u' etc are integers. 'f' is a float. Get it? And after that, use the strings you want to use.
if(sscanf(params, "ds", giveplayerid, reason)).
This is mostly used for ban/kick commands. the 'd' is an integer and the 's' is the string. Behind that, use the strings you wanna use in the script.
Sorry if I am unclear. I hope that you understand this
Another example of how to use sscanf with zcmd:
pawn Код:
COMMAND:me(playerid, params[])
{
    new text[128], string[128];
    if(sscanf(params, "s[64]", text)) return SendClientMessage(playerid, COLOR_WHITE, "ERROR » That's not the way, try: /me (action)");
    format(string, sizeof(string), "{C688D4}** %s %s", RemoveUnderScore(playerid), text);
    NewProx(playerid, COLOR_WHITE, string, 30.0);
    return 1;
}
Reply


Messages In This Thread
Big "strtok" error/bug. - by linuxthefish - 04.01.2011, 18:33
Re: Big "strtok" error/bug. - by Kwarde - 04.01.2011, 18:37
Re: Big "strtok" error/bug. - by _rAped - 04.01.2011, 18:39
Re: Big "strtok" error/bug. - by linuxthefish - 04.01.2011, 18:40
Re: Big "strtok" error/bug. - by Kwarde - 04.01.2011, 18:44
Re: Big "strtok" error/bug. - by _rAped - 04.01.2011, 18:46
Re: Big "strtok" error/bug. - by Kwarde - 04.01.2011, 18:47
Re: Big "strtok" error/bug. - by linuxthefish - 04.01.2011, 18:55
Re: Big "strtok" error/bug. - by Sergei - 04.01.2011, 19:04
Re: Big "strtok" error/bug. - by Kwarde - 04.01.2011, 19:33

Forum Jump:


Users browsing this thread: 1 Guest(s)