Честно сказать - затея не очень хорошая.
Исправил код, не много оптимизировал.
pawn Код:
//============================================================================//
//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;
}