Доступ к архиву

Переход в группу "Пользователь"

300.00 ₽
Одноразовый платёж
Быстрый переход в группу "Пользователи", без надобности написания постов и ожидания.

Покупка дает возможность:
Быть полноправным участником форума
Нормальное копирование кода
Создавать темы
Скачивать файлы
Доступ к архиву Pawno-Info

Проблемка с функцией ReturnUser на ZCMD

Статус
В этой теме нельзя размещать новые ответы.

DeNCHiK01

Ученик
Приветствую
Как многие наверное знают, есть команда /id, которая выдает id игрока и ник, при вводе id, либо ника:
Код:
if(strcmp(cmd, "/id", true) == 0)
	{
			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_WHITE, "::: Введите: /id [id/ник]");
			new target;
			target = ReturnUser(tmp);
			new sstring[256];
			if(IsPlayerConnected(target))
			{
			    if(target != INVALID_PLAYER_ID)
			    {
					GetPlayerName(target, giveplayer, sizeof(giveplayer));
					format(sstring, sizeof(sstring), "[%d] %s",target,giveplayer);
					SendClientMessage(playerid, COLOR_WHITE, sstring);
				}
				else
				{
				SendClientMessage(playerid, COLOR_GREY, "[Ошибка] Игрок не найден!");
				return 1;
				}
			}
		return 1;
	}
В основе этой функции лежит функция ReturnUser;
Код:
ReturnUser(text[], playerid = INVALID_PLAYER_ID)
{
	new pos = 0;
	while (text[pos] < 0x21) // Strip out leading spaces
	{
		if (text[pos] == 0) return INVALID_PLAYER_ID; // No passed text
		pos++;
	}
	new userid = INVALID_PLAYER_ID;
	if (IsNumeric(text[pos])) // Check whole passed string
	{
		// If they have a numeric name you have a problem (although names are checked on id failure)
		userid = strval(text[pos]);
		if (userid >=0 && userid < MAX_PLAYERS)
		{
			if(!IsPlayerConnected(userid))
			{
				/*if (playerid != INVALID_PLAYER_ID)
				{
					SendClientMessage(playerid, 0xFF0000AA, "User not connected");
				}*/
				userid = INVALID_PLAYER_ID;
			}
			else
			{
				return userid; // A player was found
			}
		}
		/*else
		{
			if (playerid != INVALID_PLAYER_ID)
			{
				SendClientMessage(playerid, 0xFF0000AA, "Invalid user ID");
			}
			userid = INVALID_PLAYER_ID;
		}
		return userid;*/
		// Removed for fallthrough code
	}
	// They entered [part of] a name or the id search failed (check names just incase)
	new len = strlen(text[pos]);
	new count = 0;
	new name[MAX_PLAYER_NAME];
	for (new i = 0; i < MAX_PLAYERS; i++)
	{
		if (IsPlayerConnected(i))
		{
			GetPlayerName(i, name, sizeof (name));
			if (strcmp(name, text[pos], true, len) == 0) // Check segment of name
			{
				if (len == strlen(name)) // Exact match
				{
					return i; // Return the exact player on an exact match
					// Otherwise if there are two players:
					// Me and MeYou any time you entered Me it would find both
					// And never be able to return just Me's id
				}
				else // Partial match
				{
					count++;
					userid = i;
				}
			}
		}
	}
	if (count != 1)
	{
		if (playerid != INVALID_PLAYER_ID)
		{
			if (count)
			{
				SendClientMessage(playerid, 0xFF0000AA, "Multiple users found, please narrow earch");
			}
			else
			{
				SendClientMessage(playerid, 0xFF0000AA, "No matching user found");
			}
		}
		userid = INVALID_PLAYER_ID;
	}
	return userid; // INVALID_USER_ID for bad return
}
IsNumeric(const string[])
{
	for (new i = 0, j = strlen(string); i < j; i++)
	{
		if (string[i] > '9' || string[i] < '0') return 0;
	}
	return 1;
}
Возник вопрос:
Как переделать функцию /id на ZCMD
Потому что, когда я делаю следующее:
Код:
CMD:id(playerid,params[])
{
	new targetid;
	new giveplayer[MAX_PLAYER_NAME];
	if(sscanf(params,"d",targetid)) return SendClientMessage(playerid, COLOR_WHITE, "Введите: /id [id/ник]");
	new target;
	target = ReturnUser(targetid);
	new sstring[256];
	if(IsPlayerConnected(target))
	{
		if(target != INVALID_PLAYER_ID)
		{   
			GetPlayerName(target, giveplayer, sizeof(giveplayer));
			format(sstring, sizeof(sstring), "[%d] %s",target,giveplayer);
			SendClientMessage(playerid, COLOR_WHITE, sstring);
		}
		else
		{
			SendClientMessage(playerid, COLOR_GREY, "Игрок не найден!");
			return 1;
		}
	}
	return 1;
}
Выдает: error 035: argument type mismatch (argument 1) на строке target = ReturnUser(targetid);
Т.е. по коду ReturnUser должна принимать 2 аргумента и в ZCMD c 1 аргументом ничего не работает, но в стандарте все работает! Я не могу понять почему так происходит, и как сделать так чтобы в ZCMD заработало?

Буду премного благодарен.
 
Статус
В этой теме нельзя размещать новые ответы.
Сверху Снизу