sscanf with default syntax? Problems with /pm command
#1

Ahoy friends.

Currently im trying to find a way to get this /pm command working.

Код:
	if(strcmp(cmd, "/pm", true) == 0)
	{
	new str[256], str2[256], id, Name1[MAX_PLAYER_NAME], Name2[MAX_PLAYER_NAME];
	if(sscanf(cmdtext, "us", id, str2))
	{
		SendClientMessage(playerid, 0xFF0000FF, "Usage: /pm <id> <message>");
		return 1;
	}
	if(!IsPlayerConnected(id)) return SendClientMessage(playerid, 0xFF0000FF, "ERROR: Player not connected");
	if(playerid == id) return SendClientMessage(playerid, 0xFF0000FF, "ERROR: You cannot pm yourself!");
	{
		GetPlayerName(playerid, Name1, sizeof(Name1));
		GetPlayerName(id, Name2, sizeof(Name2));
		format(str, sizeof(str), "PM To %s(ID %d): %s", Name2, id, str2);
		SendClientMessage(playerid, 0xFF0000FF, str);
		format(str, sizeof(str), "PM From %s(ID %d): %s", Name1, playerid, str2);
		SendClientMessage(id, 0xFF0000FF, str);
	}
	return 1;
	}
unfortunately i didnt use sscanf yet. Only the way with strtok but i heard sscanf should higher the efficieny so i would be glad to receive some help and examples.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)