Text in chat eroare copilare[rezolvat]

Tutoriale scripting, cod si portiuni de cod.

Moderators: Moderatori ajutatori, Moderatori, Echipa eXtreamCS.com

Post Reply
User avatar
DozerRadu
Membru, skill 0
Membru, skill 0
Posts: 59
Joined: 24 Jun 2017, 23:57
Detinator Steam: Da
Fond eXtream: 0
Location: Sânnicolau Mare
Has thanked: 1 time

23 Apr 2020, 22:25

Code: Select all

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "text in chat"
#define VERSION "1.0"
#define AUTHOR "n0talaMa.amxx"


enum ChatColor
{
   CHATCOLOR_YELLOW = 1,    // GALBEN
   CHATCOLOR_GREEN,    // VERDE
   CHATCOLOR_TEAM_COLOR,    // Culaore, in dependenta de echipa. (T - Rosu, CT - Albastru, SPEC - Sur)
   CHATCOLOR_GREY,    // SUR
   CHATCOLOR_RED,       // ROSU
   CHATCOLOR_BLUE,    // ALBASTRU
}

new g_TeamName[][] =
{
   "",
   "TERRORIST",
   "CT",
   "SPECTATOR"
}

new g_msgSayText
new g_msgTeamInfo
 

public plugin_init()
{
   register_plugin(PLUGIN, VERSION, AUTHOR)
   
   register_cvar("text_chat", "1")
   register_cvar("text_chat_interval", "40")
   
   register_cvar("text_chat_1", "TEXT NUMARUL 1")
   register_cvar("text_chat_2", "*TEXT NUMARUL 2"&#41;
   register_cvar("text_chat_3", "*TEXT NUMARUL 3")
   register_cvar("text_chat_4", "*TEXT NUMARUL 4")
   register_cvar("text_chat_5", "*TEXT NUMARUL 5")
   
   g_msgSayText = get_user_msgid("SayText")
   g_msgTeamInfo = get_user_msgid("TeamInfo")
}

public plugin_cfg()
{
  set_task(get_cvar_float("text_chat_interval"), "showMsg", 12345, "", _, "b")
}

public showMsg()
{
  if(get_cvar_num("text_chat") == 1)
  {
    static
            msg1[128],
            msg2[128],
            msg3[128],
            msg4[128],
            msg5[128]
   
    get_cvar_string("text_chat_1", msg1, 127)
    get_cvar_string("text_chat_2", msg2, 127)
    get_cvar_string("text_chat_3", msg3, 127)
    get_cvar_string("text_chat_4", msg4, 127)
    get_cvar_string("text_chat_5", msg5, 127)
   
    colorChat(0, CHATCOLOR_YELLOW, "%s", msg1)
    colorChat(0, CHATCOLOR_RED, "%s", msg2)
    colorChat(0, CHATCOLOR_GREEN, "%s", msg3)
    colorChat(0, CHATCOLOR_GREY, "%s", msg4)
    colorChat(0, CHATCOLOR_BLUE, "%s", msg5)
  }
}

colorChat(id, ChatColor:color, const msg[], {Float,Sql,Result,_}:...)
{
   new team, index, MSG_Type
   new bool:teamChanged = false
   new message[192]
   
   switch(color)
   {
      case CHATCOLOR_YELLOW:
      {
         message[0] = 0x01;
      }
      case CHATCOLOR_GREEN:
      {
         message[0] = 0x04;
      }
      default:
      {
         message[0] = 0x03;
      }
   }
   
   vformat(message[1], 190, msg, 4);
   
   if (id == 0)
   {
      index = findAnyPlayer();
      MSG_Type = MSG_ALL;
   }
   else
   {
      index = id;
      MSG_Type = MSG_ONE;
   }
   if (index != 0)
   {
      team = get_user_team(index);   
      if (color == CHATCOLOR_RED && team != 1)
      {
         messageTeamInfo(index, MSG_Type, g_TeamName[1])
         teamChanged = true
      }
      else
      if (color == CHATCOLOR_BLUE && team != 2)
      {
         messageTeamInfo(index, MSG_Type, g_TeamName[2])
         teamChanged = true
      }
      else
      if (color == CHATCOLOR_GREY && team != 0)
      {
         messageTeamInfo(index, MSG_Type, g_TeamName[0])
         teamChanged = true
      }
      messageSayText(index, MSG_Type, message);
      if (teamChanged)
      {
         messageTeamInfo(index, MSG_Type, g_TeamName[team]);
      }
   }
}

messageSayText(id, type, message[])
{
   message_begin(type, g_msgSayText, _, id)
   write_byte(id)      
   write_string(message)
   message_end()
}
   
messageTeamInfo(id, type, team[])
{
   message_begin(type, g_msgTeamInfo, _, id)
   write_byte(id)
   write_string(team)
   message_end()
}
   
findAnyPlayer()
{
   new players[32], inum
   
   get_players(players, inum)
   
   for (new a = 0; a < inum; ++a)
   {
      if(is_user_connected(players[a]))
      {
         return players[a]
      }
   }
   return 0
}
Imi da eroare la compiler . :concerned:

Code: Select all

/tmp/textllHMmL.sma(39) : error 029: invalid expression, assumed zero
/tmp/textllHMmL.sma(39) : warning 215: expression has no effect

1 Error.
Could not locate output file /home/groups/amxmodx/public_html/websc3/textllHMmL.amx (compile failed).
Last edited by C.Artur on 26 Apr 2020, 09:54, edited 2 times in total.
Reason: Subiect marcat ca rezolvat.
Zonek
User avatar
trekA
Super moderator
Super moderator
Posts: 332
Joined: 09 Mar 2019, 23:13
Detinator Steam: Da
CS Status: WIDO.PLAYARENA.RO
SteamID: picanetu
Reputatie: Super moderator
Membru Club eXtreamCS (17 Feb - 17 Mai)
Fond eXtream: 0
Location: Piatra Neamț
Has thanked: 65 times
Been thanked: 23 times
Contact:

23 Apr 2020, 22:25

Ar ajuta mai mult daca ai spune si ce eroare da in compiler.
Din ce vad nu ai "include <colorchat>" in cod.
Image
User avatar
DozerRadu
Membru, skill 0
Membru, skill 0
Posts: 59
Joined: 24 Jun 2017, 23:57
Detinator Steam: Da
Fond eXtream: 0
Location: Sânnicolau Mare
Has thanked: 1 time

23 Apr 2020, 23:55

trekA wrote:
23 Apr 2020, 22:25
Ar ajuta mai mult daca ai spune si ce eroare da in compiler.
Din ce vad nu ai "include <colorchat>" in cod.

Code: Select all

/tmp/textllHMmL.sma(39) : error 029: invalid expression, assumed zero
/tmp/textllHMmL.sma(39) : warning 215: expression has no effect

1 Error.
Could not locate output file /home/groups/amxmodx/public_html/websc3/textllHMmL.amx (compile failed).
User avatar
L E V I N
Scripter eXtreamCS
Scripter eXtreamCS
Posts: 2967
Joined: 24 Aug 2011, 11:24
Detinator Steam: Da
CS Status:
Detinator server CS: ☯∴
SteamID: riseofevo
Reputatie: Scripter eXtreamCS
Nume anterior: Adryyy
Location: ҳ̸Ҳ̸ҳ
Has thanked: 39 times
Been thanked: 454 times
Contact:

24 Apr 2020, 13:33

Code: Select all

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "text in chat"
#define VERSION "1.0"
#define AUTHOR "n0talaMa.amxx"


enum ChatColor
{
   CHATCOLOR_YELLOW = 1,    // GALBEN
   CHATCOLOR_GREEN,    // VERDE
   CHATCOLOR_TEAM_COLOR,    // Culaore, in dependenta de echipa. (T - Rosu, CT - Albastru, SPEC - Sur)
   CHATCOLOR_GREY,    // SUR
   CHATCOLOR_RED,       // ROSU
   CHATCOLOR_BLUE,    // ALBASTRU
}

new g_TeamName[][] =
{
   "",
   "TERRORIST",
   "CT",
   "SPECTATOR"
}

new g_msgSayText
new g_msgTeamInfo
 

public plugin_init()
{
   register_plugin(PLUGIN, VERSION, AUTHOR)
   
   register_cvar("text_chat", "1")
   register_cvar("text_chat_interval", "40")
   
   register_cvar("text_chat_1", "TEXT NUMARUL 1")
   register_cvar("text_chat_2", "*TEXT NUMARUL 2")
   register_cvar("text_chat_3", "*TEXT NUMARUL 3")
   register_cvar("text_chat_4", "*TEXT NUMARUL 4")
   register_cvar("text_chat_5", "*TEXT NUMARUL 5")
   
   g_msgSayText = get_user_msgid("SayText")
   g_msgTeamInfo = get_user_msgid("TeamInfo")
}

public plugin_cfg()
{
  set_task(get_cvar_float("text_chat_interval"), "showMsg", 12345, "", _, "b")
}

public showMsg()
{
  if(get_cvar_num("text_chat") == 1)
  {
    static
            msg1[128],
            msg2[128],
            msg3[128],
            msg4[128],
            msg5[128]
   
    get_cvar_string("text_chat_1", msg1, 127)
    get_cvar_string("text_chat_2", msg2, 127)
    get_cvar_string("text_chat_3", msg3, 127)
    get_cvar_string("text_chat_4", msg4, 127)
    get_cvar_string("text_chat_5", msg5, 127)
   
    colorChat(0, CHATCOLOR_YELLOW, "%s", msg1)
    colorChat(0, CHATCOLOR_RED, "%s", msg2)
    colorChat(0, CHATCOLOR_GREEN, "%s", msg3)
    colorChat(0, CHATCOLOR_GREY, "%s", msg4)
    colorChat(0, CHATCOLOR_BLUE, "%s", msg5)
  }
}

colorChat(id, ChatColor:color, const msg[], {Float,Sql,Result,_}:...)
{
   new team, index, MSG_Type
   new bool:teamChanged = false
   new message[192]
   
   switch(color)
   {
      case CHATCOLOR_YELLOW:
      {
         message[0] = 0x01;
      }
      case CHATCOLOR_GREEN:
      {
         message[0] = 0x04;
      }
      default:
      {
         message[0] = 0x03;
      }
   }
   
   vformat(message[1], 190, msg, 4);
   
   if (id == 0)
   {
      index = findAnyPlayer();
      MSG_Type = MSG_ALL;
   }
   else
   {
      index = id;
      MSG_Type = MSG_ONE;
   }
   if (index != 0)
   {
      team = get_user_team(index);   
      if (color == CHATCOLOR_RED && team != 1)
      {
         messageTeamInfo(index, MSG_Type, g_TeamName[1])
         teamChanged = true
      }
      else
      if (color == CHATCOLOR_BLUE && team != 2)
      {
         messageTeamInfo(index, MSG_Type, g_TeamName[2])
         teamChanged = true
      }
      else
      if (color == CHATCOLOR_GREY && team != 0)
      {
         messageTeamInfo(index, MSG_Type, g_TeamName[0])
         teamChanged = true
      }
      messageSayText(index, MSG_Type, message);
      if (teamChanged)
      {
         messageTeamInfo(index, MSG_Type, g_TeamName[team]);
      }
   }
}

messageSayText(id, type, message[])
{
   message_begin(type, g_msgSayText, _, id)
   write_byte(id)      
   write_string(message)
   message_end()
}
   
messageTeamInfo(id, type, team[])
{
   message_begin(type, g_msgTeamInfo, _, id)
   write_byte(id)
   write_string(team)
   message_end()
}
   
findAnyPlayer()
{
   new players[32], inum
   
   get_players(players, inum)
   
   for (new a = 0; a < inum; ++a)
   {
      if(is_user_connected(players[a]))
      {
         return players[a]
      }
   }
   return 0
}
Faceți cerere bine detaliată aici și respectând modelul dacă vreți ajutor. Nu-mi mai dați add doar pentru a mă avea în lista de prieteni.
Am cont și activez doar aici! Aveți grijă la cei ce încearcă să mă copieze..Puteți lua legătura cu mine dacă aveți o problemă/nelămurire în acest caz!
În cazul în care utilizați ceva din addonsurile postate de mine aici, e bine să fiți la curent cu modificările aduse unor plugine, aici, iar dacă sunt ceva probleme sau aveți dvs. probleme nu ezitați să luați legătura cu mine.
HOST CS1.6
User avatar
DozerRadu
Membru, skill 0
Membru, skill 0
Posts: 59
Joined: 24 Jun 2017, 23:57
Detinator Steam: Da
Fond eXtream: 0
Location: Sânnicolau Mare
Has thanked: 1 time

25 Apr 2020, 22:26

  • Multumesc frumos. :face_party_blower:
Post Reply

Return to “Scripting”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 0 guests