Доступ к готовым решениям

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

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

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

Мануал /recon на TextDraws

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

vitalik6243

Умник
Систему писал сам для своего мода. Таких тем вроде не видел.
И так начнем:

В начало мода:
PHP:
#define         COLOR_GOLD    		0xFFD700FF
#define 		COLOR_GREY 			0xAFAFAFAA
new Text:TRECON[8],PlayerText:TEXTRECON[MAX_PLAYERS];
В OnGameModeInit:
PHP:
TRECON[0] = TextDrawCreate(8.000000, 160.000000, "Update");
	TextDrawBackgroundColor(TRECON[0], 255);
	TextDrawFont(TRECON[0], 1);
	TextDrawLetterSize(TRECON[0], 0.409999, 1.700000);
	TextDrawColor(TRECON[0], 65535);
	TextDrawSetOutline(TRECON[0], 1);
	TextDrawSetProportional(TRECON[0], 1);
	TextDrawUseBox(TRECON[0], 1);
	TextDrawBoxColor(TRECON[0], -208);
	TextDrawTextSize(TRECON[0], 57.000000, 13.000000);
	TextDrawSetSelectable(TRECON[0], 1);
	TRECON[1] = TextDrawCreate(8.000000, 180.000000, "GM Test");
	TextDrawBackgroundColor(TRECON[1], 255);
	TextDrawFont(TRECON[1], 1);
	TextDrawLetterSize(TRECON[1], 0.409999, 1.600000);
	TextDrawColor(TRECON[1], 65535);
	TextDrawSetOutline(TRECON[1], 1);
	TextDrawSetProportional(TRECON[1], 1);
	TextDrawUseBox(TRECON[1], 1);
	TextDrawBoxColor(TRECON[1], -208);
	TextDrawTextSize(TRECON[1], 65.000000, 13.000000);
	TextDrawSetSelectable(TRECON[1], 1);
	TRECON[2] = TextDrawCreate(8.000000, 199.000000, "Mute");
	TextDrawBackgroundColor(TRECON[2], 255);
	TextDrawFont(TRECON[2], 1);
	TextDrawLetterSize(TRECON[2], 0.409999, 1.600000);
	TextDrawColor(TRECON[2], 65535);
	TextDrawSetOutline(TRECON[2], 1);
	TextDrawSetProportional(TRECON[2], 1);
	TextDrawUseBox(TRECON[2], 1);
	TextDrawBoxColor(TRECON[2], -208);
	TextDrawTextSize(TRECON[2], 41.000000, 13.000000);
	TextDrawSetSelectable(TRECON[2], 1);
	TRECON[3] = TextDrawCreate(8.000000, 218.000000, "Kick");
	TextDrawBackgroundColor(TRECON[3], 255);
	TextDrawFont(TRECON[3], 1);
	TextDrawLetterSize(TRECON[3], 0.409999, 1.600000);
	TextDrawColor(TRECON[3], 65535);
	TextDrawSetOutline(TRECON[3], 1);
	TextDrawSetProportional(TRECON[3], 1);
	TextDrawUseBox(TRECON[3], 1);
	TextDrawBoxColor(TRECON[3], -208);
	TextDrawTextSize(TRECON[3], 36.000000, 13.000000);
	TextDrawSetSelectable(TRECON[3], 1);
	TRECON[4] = TextDrawCreate(8.000000, 237.100006, "Slap");
	TextDrawBackgroundColor(TRECON[4], 255);
	TextDrawFont(TRECON[4], 1);
	TextDrawLetterSize(TRECON[4], 0.409999, 1.600000);
	TextDrawColor(TRECON[4], 65535);
	TextDrawSetOutline(TRECON[4], 1);
	TextDrawSetProportional(TRECON[4], 1);
	TextDrawUseBox(TRECON[4], 1);
	TextDrawBoxColor(TRECON[4], -208);
	TextDrawTextSize(TRECON[4], 36.000000, 13.000000);
	TextDrawSetSelectable(TRECON[4], 1);
	TRECON[5] = TextDrawCreate(8.000000, 256.299987, "Stats");
	TextDrawBackgroundColor(TRECON[5], 255);
	TextDrawFont(TRECON[5], 1);
	TextDrawLetterSize(TRECON[5], 0.409999, 1.600000);
	TextDrawColor(TRECON[5], 65535);
	TextDrawSetOutline(TRECON[5], 1);
	TextDrawSetProportional(TRECON[5], 1);
	TextDrawUseBox(TRECON[5], 1);
	TextDrawBoxColor(TRECON[5], -208);
	TextDrawTextSize(TRECON[5], 43.000000, 13.000000);
	TextDrawSetSelectable(TRECON[5], 1);
	TRECON[6] = TextDrawCreate(8.000000, 275.299987, "Get IP");
	TextDrawBackgroundColor(TRECON[6], 255);
	TextDrawFont(TRECON[6], 1);
	TextDrawLetterSize(TRECON[6], 0.409999, 1.600000);
	TextDrawColor(TRECON[6], 65535);
	TextDrawSetOutline(TRECON[6], 1);
	TextDrawSetProportional(TRECON[6], 1);
	TextDrawUseBox(TRECON[6], 1);
	TextDrawBoxColor(TRECON[6], -208);
	TextDrawTextSize(TRECON[6], 52.000000, 13.000000);
	TextDrawSetSelectable(TRECON[6], 1);
	TRECON[7] = TextDrawCreate(8.000000, 294.500000, "OFF");
	TextDrawBackgroundColor(TRECON[7], 255);
	TextDrawFont(TRECON[7], 1);
	TextDrawLetterSize(TRECON[7], 0.409999, 1.600000);
	TextDrawColor(TRECON[7], 65535);
	TextDrawSetOutline(TRECON[7], 1);
	TextDrawSetProportional(TRECON[7], 1);
	TextDrawUseBox(TRECON[7], 1);
	TextDrawBoxColor(TRECON[7], -208);
	TextDrawTextSize(TRECON[7], 33.000000, 13.000000);
	TextDrawSetSelectable(TRECON[7], 1);
В OnPlayerConnect:
PHP:
TEXTRECON[playerid] = CreatePlayerTextDraw(playerid,422.000000, 175.000000, "~b~]Nick: ~g~Nick~n~~b~]ID: ~g~0~n~~b~]IP: ~g~0~n~~b~]Armour: ~g~0~n~~b~]HP: ~g~0~n~~b~]CARHP: ~g~0~n~~b~]Money: ~g~0~n~~b~]Ammo: ~g~0~n~~b~]Ping: ~g~0~n~~b~]Speed: ~g~0");
	PlayerTextDrawBackgroundColor(playerid,TEXTRECON[playerid], 255);
	PlayerTextDrawFont(playerid,TEXTRECON[playerid], 2);
	PlayerTextDrawLetterSize(playerid,TEXTRECON[playerid], 0.380000, 1.000000);
	PlayerTextDrawColor(playerid,TEXTRECON[playerid], -1);
	PlayerTextDrawSetOutline(playerid,TEXTRECON[playerid], 1);
	PlayerTextDrawSetProportional(playerid,TEXTRECON[playerid], 1);
	PlayerTextDrawSetSelectable(playerid,TEXTRECON[playerid], 0);
В OnGameModeExit:
PHP:
for(new td; td != 8; td++) TextDrawDestroy(TRECON[td]);
В OnPlayerCommandText:
PHP:
if(!strcmp(cmd, "/recon", true) || !strcmp(cmd, "/re", true))
	{
		if(pData[playerid][pAdmin] < 4 || !gAdminLogin[playerid]) return true;
		if(reconid[playerid] != INVALID_PLAYER_ID) return StopRecon(playerid);
		if(sscanf(params,"d",params[0])) return SCM(playerid, COLOR_GOLD,"Используйте: (/re)con [ид]");
		if(!IsPlayerNPC(params[0]) && (!gPlayerLogged[params[0]] || playerid == params[0])) return SCM(playerid,COLOR_GREY,"Данного игрока нет на сервере / он не авторизован / указали свой ид!");
		if(pData[params[0]][pAdmin] >= pData[playerid][pAdmin]) return SCM(playerid,COLOR_GREY,"За этим администратором нельзя следить!");
		reconid[playerid] = params[0];
		return StartRecon(playerid);
	}
Я использую процессор обычных команд + sscanf.
PHP:
pData[playerid][pAdmin] < 4\ //Проверка на админку
|| !gAdminLogin[playerid]//Авторизовался ли игрок под администратором
В OnPlayerUpdate:
PHP:
if(reconid[playerid] != INVALID_PLAYER_ID)
	{
		new id = reconid[playerid],Float:X,Float:Y,Float:Z;
		if(IsPlayerInAnyVehicle(id)) GetVehicleVelocity(vehicle(id),X,Y,Z);
		else GetPlayerVelocity(id,X,Y,Z);
		new Float:speed = floatsqroot(floatadd(floatadd(floatpower(X, 2), floatpower(Y, 2)),  floatpower(Z, 2))) * 126.31;
		format(allstring,sizeof(allstring),"~b~]Nick: ~g~%s~n~~b~]ID: ~g~%d~n~~b~]IP: ~g~%s~n~~b~]Armour: ~g~%.0f~n~~b~]HP: ~g~%.0f~n~~b~]CARHP: ~g~%.0f~n~~b~]Money: ~g~%d~n~~b~]Ammo: ~g~%d~n~~b~]Ping: ~g~%d~n~~b~]Speed: ~g~%.0f",
		pData[id][pName],id,pData[id][pIp],pData[id][pArmour],pData[id][pHealth],vehicle(id),pData[id][pCash],GetPlayerAmmo(id),GetPlayerPing(id),speed);
		PlayerTextDrawSetString(playerid, TEXTRECON[playerid], allstring);
	}
В OnPlayerClickTextDraw:
PHP:
if(clickedid == TRECON[0]) return StartRecon(playerid);
	else if(clickedid == TRECON[1])
	{
		format(allstring,sizeof(allstring),"/gm %d",reconid[playerid]);
		return OnPlayerCommandText(playerid,allstring);
	}
	else if(clickedid == TRECON[2])
	{
		format(allstring,sizeof(allstring),"/mute %d 5 In Recon",reconid[playerid]);
		return OnPlayerCommandText(playerid,allstring);
	}
	else if(clickedid == TRECON[3])
	{
		format(allstring,sizeof(allstring),"/skick %d",reconid[playerid]);
		return OnPlayerCommandText(playerid,allstring);
	}
	else if(clickedid == TRECON[4])
	{
		format(allstring,sizeof(allstring),"/slap %d",reconid[playerid]);
		return OnPlayerCommandText(playerid,allstring);
	}
	else if(clickedid == TRECON[5]) return ShowStats(reconid[playerid],playerid);
	else if(clickedid == TRECON[6])
	{
		format(allstring,sizeof(allstring),"/getip %d",reconid[playerid]);
		return OnPlayerCommandText(playerid,allstring);
	}
	else if(clickedid == TRECON[7]) return StopRecon(playerid);
В конец мода:
PHP:
stock StartRecon(playerid)
{
	if(reconid[playerid] == INVALID_PLAYER_ID) return true;
	for(new i = 0; i != 8; i++) TextDrawShowForPlayer(playerid, TRECON[i]);
	PlayerTextDrawShow(playerid,TEXTRECON[playerid]);
	SelectTextDraw(playerid, 0xFF4040AA);
	SetPlayerInterior(playerid,GetPlayerInterior(reconid[playerid]));
	SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(reconid[playerid]));
	TogglePlayerSpectating(playerid, true);
	if(IsPlayerInAnyVehicle(reconid[playerid])) PlayerSpectateVehicle(playerid, vehicle(reconid[playerid]));
	else PlayerSpectatePlayer(playerid, reconid[playerid]);
	return true;
}

stock StopRecon(playerid)
{
	if(reconid[playerid] == INVALID_PLAYER_ID) return true;
	if(IsPlayerConnected(reconid[playerid])) GameTextForPlayer(playerid,"~w~recon ~r~off~n~~r~player disconnect", 2000, 4);
	else GameTextForPlayer(playerid,"~w~recon ~r~off", 2000, 4);
	for(new i = 0; i != 8; i++) TextDrawHideForPlayer(playerid, TRECON[i]);
	PlayerTextDrawHide(playerid,TEXTRECON[playerid]);
	CancelSelectTextDraw(playerid);
	reconid[playerid] = INVALID_PLAYER_ID;
	TogglePlayerSpectating(playerid, false);
	return true;
}
Если выдает ошибки и в ошибках есть: "pName"
Добавьте:
В OnPlayerConnect:
PHP:
GetPlayerName(playerid,pData[playerid][pName],MAX_PLAYER_NAME);
В enum pInfo:
PHP:
pName[MAX_PLAYER_NAME]
На этом все.
Я думаю все написано оптимизировно и займет очень мало строк.
Автор: vitalik6243(я)


Скрнишот сделан с NPC бота поэтому на статистике не отображается Ник,Ip и прочая информация.
Если смотреть на обычном игроке то все будет нормально.
 
Последнее редактирование:
Статус
В этой теме нельзя размещать новые ответы.
Сверху Снизу