TheJIsusGang
Специалист
Здравствуйте, уважаемые пользователи.
Хочу вам представить систему информационных окошек с помощью, как в одиночной игре. Возможно вы уже видели что-то подобное, но моя система более облегчена и приближена к оригиналу.
И так начнём:
Добавляем ко всем new:
PHP:
new PlayerText:INFO_BOX[2];
new bool:ShowInfoBox[MAX_PLAYERS];
PHP:
forward OnInfoBoxUpdate();
PHP:
SetTimer("OnInfoBoxUpdate", 1000, true);
PHP:
CreateInfoBox(playerid, 450, 100);
ShowInfoBox[playerid] = false;
PHP:
public OnInfoBoxUpdate()
{
foreach(new i : Player)
{
if(ShowInfoBox[i])
{
if(GetPVarInt(i,"InfoBox") < gettime())
{
PlayerTextDrawHide(i, INFO_BOX[1]);
PlayerTextDrawHide(i, INFO_BOX[0]);
ShowInfoBox[i] = false;
}
}
}
}
PHP:
stock CreateInfoBox(playerid, Float:posX, Float:posY)
{
INFO_BOX[0] = CreatePlayerTextDraw(playerid, posX, posY, "usebox"); SetPlayerTextDrawSettings(playerid, INFO_BOX[0],0,6.5, 185+posX,0, 1, 0, 0,0,110, 0,0, false, true, false);
INFO_BOX[1] = CreatePlayerTextDraw(playerid, posX, posY+0.5, ""); SetPlayerTextDrawSettings(playerid, INFO_BOX[1],0.42,2, 0,0, 1, 1, 0xB6B2B5FF,0,0, 0,0, false, false, true);
return true;
}
stock DrawInfoBoxForPlayer(playerid, message[], time)
{
new lines;
for(new i = 0; i < strlen(message); i++)
{
switch(message[i])
{
case 'n': lines++;
}
}
PlayerTextDrawLetterSize(playerid, INFO_BOX[0], 0, (lines+1) * 2.16);
PlayerTextDrawSetString(playerid, INFO_BOX[1], message);
PlayerTextDrawShow(playerid, INFO_BOX[1]);
PlayerTextDrawShow(playerid, INFO_BOX[0]);
SetPVarInt(playerid,"InfoBox",gettime() + time);
ShowInfoBox[playerid] = true;
return true;
}
stock SetPlayerTextDrawSettings(playerid, PlayerText:TextDraw, Float:Lsize1, Float:Lsize2, Float:Tsize1, Float:Tsize2, Alignment, Font, Color1, Color2, Color3, Shadows, Outline, bool:Selectable, bool:UseBox, bool:Proportional)
{
PlayerTextDrawLetterSize(playerid, TextDraw, Lsize1, Lsize2);
if(Tsize1 == 0 && Tsize2 == 0){}
else PlayerTextDrawTextSize(playerid, TextDraw, Tsize1, Tsize2);
PlayerTextDrawAlignment(playerid, TextDraw, Alignment);
PlayerTextDrawFont(playerid, TextDraw, Font);
PlayerTextDrawColor(playerid, TextDraw, Color1);
PlayerTextDrawBackgroundColor(playerid, TextDraw, Color2);
PlayerTextDrawBoxColor(playerid, TextDraw, Color3);
PlayerTextDrawSetShadow(playerid, TextDraw, Shadows);
PlayerTextDrawSetOutline(playerid, TextDraw, Outline);
PlayerTextDrawSetSelectable(playerid, TextDraw, Selectable);
PlayerTextDrawUseBox(playerid, TextDraw, UseBox);
PlayerTextDrawSetProportional(playerid, TextDraw, Proportional);
return true;
}
PHP:
if(!strcmp(cmd,"/connectfaq",true))
{
new str[264];
strcat(str, "~w~Welcome to -~n~");
strcat(str, "~r~Brilliant RP - Amethyst~n~");
strcat(str, "~w~Good game you!");
DrawInfoBoxForPlayer(playerid, str, 30);
}
Можно придумать что либо, с использованием данной функции, подскажите что можно сделать
Можно еще добавить при OnPlayerSpawn (при спавне игрока):
PHP:
new str[264];
strcat(str, "~w~Welcome to -~n~");
strcat(str, "~r~Brilliant RP - Amethyst~n~");
strcat(str, "~w~Good game you!");
DrawInfoBoxForPlayer(playerid, str, 30);
Последнее редактирование:
