#define MAX_MESSAGES 100
#define SendClientMessage SCM_SendClientMessage
#define SendClientMessageToAll SCM_SendClientMessageToAll
#define PlayAudioStreamForPlayer SCM_PlayAudioStreamForPlayer
enum SCM_Data = {
SCM_Text[144 + MAX_PLAYER_NAME + 16],
SCM_Color,
SCM_Sender[MAX_PLAYER_NAME],
};
new SCM_Page[MAX_MESSAGES][SCM_Data], SCM_Counter;
public OnPlayerText(playerid, text[])
{
GetPlayerName(playerid, SCM_Page[SCM_Counter][SCM_Sender], MAX_PLAYER_NAME);
format(SCM_Page[SCM_Counter][SCM_Text], sizeof(SCM_Page[SCM_Counter][SCM_Text]), "%s: {FFFFFF}%s", SCM_Page[SCM_Counter][SCM_Sender], text);
SCM_Page[SCM_Counter][SCM_Color] = GetPlayerColor(playerid) >>> 8;
SCM_Counter++;
if(SCM_Counter == MAX_MESSAGES)
{
for(new i = 1; i <= MAX_MESSAGES; i++)
{
SCM_Page[i - 1][SCM_Color] = SCM_Page[i][SCM_Color];
SCM_Page[i - 1][SCM_Text] = SCM_Page[i][SCM_Text];
}
SCM_Counter--;
}
return 1;
}
stock SCM_SendClientMessage(playerid, color, text[])
{
SCM_Page[SCM_Counter][SCM_Text][0] = EOS;
strcat(SCM_Page[SCM_Counter][SCM_Text], text);
SCM_Page[SCM_Counter][SCM_Color] = color;
SendClientMessage(playerid, SCM_Page[SCM_Counter][SCM_Color], SCM_Page[SCM_Counter][SCM_Text]);
SCM_Counter++;
if(SCM_Counter == MAX_MESSAGES)
{
for(new i = 1; i <= MAX_MESSAGES; i++)
{
SCM_Page[i - 1][SCM_Color] = SCM_Page[i][SCM_Color];
SCM_Page[i - 1][SCM_Text] = SCM_Page[i][SCM_Text];
}
SCM_Counter--;
}
return 1;
}
stock SCM_SendClientMessageToAll(color, text[])
{
SCM_Page[SCM_Counter][SCM_Text][0] = EOS;
strcat(SCM_Page[SCM_Counter][SCM_Text], text);
SCM_Page[SCM_Counter][SCM_Color] = color;
SendClientMessageToAll(SCM_Page[SCM_Counter][SCM_Color], SCM_Page[SCM_Counter][SCM_Text]);
SCM_Counter++;
if(SCM_Counter == MAX_MESSAGES)
{
for(new i = 1; i <= MAX_MESSAGES; i++)
{
SCM_Page[i - 1][SCM_Color] = SCM_Page[i][SCM_Color];
SCM_Page[i - 1][SCM_Text] = SCM_Page[i][SCM_Text];
}
SCM_Counter--;
}
return 1;
}
stock SCM_PlayAudioStreamForPlayer(playerid, url[], Float:PosX = 0.0, Float:PosY = 0.0, Float:PosZ = 0.0, Float:Distance = 50.0, Usepos = 0)
{
PlayAudioStreamForPlayer(playerid, url, PosX, PosY, PosZ, Distance, Usepos);
for(new i = 0; i <= SCM_Counter; i++) SendClientMessage(playerid, SCM_Page[SCM_Counter][SCM_Color], SCM_Page[SCM_Counter][SCM_Text]);
return 1;
}
//============================================================================//
//Include
#if !defined _SCM_
#define _SCM_
#include <a_samp>
#define MAX_MESSAGES 100
#define MAX_MESSAGE_LENGHT (144 + MAX_PLAYER_NAME + 16)
enum SCM_Data
{
SCM_Text[MAX_MESSAGE_LENGHT],
SCM_Color
};
new SCM_Page[MAX_PLAYERS + 1][MAX_MESSAGES][SCM_Data], SCM_Counter[MAX_PLAYERS];
stock SCM_SendClientMessage(playerid, color, text[])
{
format( SCM_Page[playerid][SCM_Counter[playerid]][SCM_Text], MAX_MESSAGE_LENGHT, "%s", text);
SendClientMessage(playerid, (SCM_Page[playerid][SCM_Counter[playerid]][SCM_Color] = color), SCM_Page[playerid][SCM_Counter[playerid]][SCM_Text] );
if((++SCM_Counter[playerid]) == MAX_MESSAGES) SCM_Counter[playerid] = 0;
return 1;
}
stock SCM_SendClientMessageToAll(color, text[])
{
format( SCM_Page[MAX_PLAYERS][0][SCM_Text], MAX_MESSAGE_LENGHT, "%s", text);
SCM_Page[MAX_PLAYERS][0][SCM_Color] = color;
for(new playerid = 0; playerid < MAX_PLAYERS; playerid++)
{
SCM_Page[playerid][SCM_Counter[playerid]] = SCM_Page[MAX_PLAYERS][0];
if((++SCM_Counter[playerid]) == MAX_MESSAGES) SCM_Counter[playerid] = 0;
}
SendClientMessageToAll(color, text);
return 1;
}
stock SCM_ClearChat(playerid, no_msg = 0)
{
SCM_Page[playerid] = SCM_Page[MAX_PLAYERS];
SCM_Counter[playerid] = 0;
if(no_msg == 0)
{
for(new i = 0; i < MAX_MESSAGES; i++) SendClientMessage(playerid, SCM_Page[playerid][i][SCM_Color], SCM_Page[playerid][i][SCM_Text]);
}
}
stock SCM_PlayAudioStreamForPlayer(playerid, url[], Float:PosX = 0.0, Float:PosY = 0.0, Float:PosZ = 0.0, Float:Distance = 50.0, Usepos = 0)
{
PlayAudioStreamForPlayer(playerid, url, PosX, PosY, PosZ, Distance, Usepos);
for(new i = SCM_Counter[playerid]; i < MAX_MESSAGES; i++) SendClientMessage(playerid, SCM_Page[playerid][SCM_Counter[playerid]][SCM_Color], SCM_Page[playerid][SCM_Counter[playerid]][SCM_Text]);
for(new i = 0; i < SCM_Counter[playerid]; i++) SendClientMessage(playerid, SCM_Page[playerid][i][SCM_Color], SCM_Page[playerid][i][SCM_Text]);
return 1;
}
#define ClearChat SCM_ClearChat
#define SendClientMessage SCM_SendClientMessage
#define SendClientMessageToAll SCM_SendClientMessageToAll
#define PlayAudioStreamForPlayer SCM_PlayAudioStreamForPlayer
#endif
//============================================================================//
//GameMode
public OnPlayerConnect(playerid)
{
ClearChat(playerid, 1);
return 1;
}
public OnPlayerText(playerid, text[])
{
new p_Name[MAX_PLAYER_NAME], p_Text[MAX_MESSAGE_LENGHT];
GetPlayerName(playerid, p_Name, MAX_PLAYER_NAME);
format( p_Text, MAX_MESSAGE_LENGHT, "%s: {FFFFFF}%s", p_Name, text);
SendClientMessageToAll((GetPlayerColor(playerid) >>> 8), p_Text);
//------ TEST ------//
if(text[0] == '1')
{
SCM_PlayAudioStreamForPlayer(playerid, "http://is-team.clan.su/Update/Sub-Mass-Histerics.mp3");
}
if(text[0] == '2')
{
SCM_SendClientMessage(playerid, 0x00FF00FF, "ololo123");
SCM_SendClientMessage(playerid, 0x00FF00FF, "ololo");
}
if(text[0] == '3')
{
SCM_SendClientMessageToAll(0xFF0000FF, "G_ololo123");
SCM_SendClientMessageToAll(0xFF0000FF, "G_ololo");
}
//------------------------------------------------------------------------//
return 0;
}
P.S. Выложенный выше код не вернет сообщения клиента. Да и оно того не стоит.
|
PlayAudioStreamForPlayer(playerid, "[текст рекомендации /audiomsg]");
PlayAudioStreamForPlayer(playerid, "[ссылка на аудио файл]");