Half-Life и Adrenaline Gamer форум

Всё об игре в Халф-Лайф и АГ
Текущее время: 28 мар 2024, 14:23

Часовой пояс: UTC + 5 часов [ Летнее время ]




Начать новую тему Ответить на тему  [ Сообщений: 4 ] 
Автор Сообщение
 Заголовок сообщения: [TUT] Set Team Scores method
СообщениеДобавлено: 17 июн 2015, 02:44 
Не в сети
Аватара пользователя
Зарегистрирован:
24 ноя 2014, 20:59
Последнее посещение:
27 май 2019, 05:57
Сообщения: 204
Откуда: Other Side
Hi ,

This tutorial will shows you how to set team scores .

I mean like this :
Изображение

First we need to make a plugin , then we need make a teams ofcourse ,

Код:
#include <amxmodx>
#include <amxmisc>

#define PLUGIN "Set Team Scores"
#define VERSION "0.01"
#define AUTHOR "TuTorial"

enum
{
TEAM_NONE = 0, // This is NULL Team and always = 0
TEAM_RED,        // This is Red Team = 1
TEAM_BLUE,       // This is Blue Team = 2
TEAM_SPEC       // This is Spectator = 3
}

fine now we need to make an Array String to hold teams name eg : "scientist" and "hgrunt"
scientist , will be the red team , and hgrunt is the blue team
like this
Код:
new const g_szHLTeams[][] =
{
"",                // Also like the first one this is NULL but this is a Sting
"scientist",     // my red team name
"hgrunt",        // my blue team name
"SPECTATOR"  //this is spectator as you know .
}

NOTE : if your Teams are not the same as my , just change "scientist" and "hgrunt" to your teams name

now we need to send message to score board
now we have this code

Код:
#include <amxmodx>
#include <amxmisc>

#define PLUGIN "Set Team Scores"
#define VERSION "0.01"
#define AUTHOR "TuTorial"

enum
{
TEAM_NONE = 0,
TEAM_RED,
TEAM_BLUE,
TEAM_SPEC
}

new const g_szHLTeams[][] =
{
"",
"scientist",
"hgrunt",
"SPECTATOR"
}


new gMsg_TeamScore
public plugin_init() {
   register_plugin(PLUGIN, VERSION, AUTHOR)
   gMsg_TeamScore = get_user_msgid("TeamScore")
   register_message(gMsg_TeamScore, "msg_teamScore")
   register_clcmd("say add", "Function") // Lets make this command to run your Function that will set team scores
   
}

first lets make an array to hold your teams
will be g_iScore[3]



Код:
new g_iScore[3]

public Function(id)
{
   new iTeam = get_user_team(id)
   switch(iTeam)
   {
      case 1: iTeam = TEAM_RED
      case 2: iTeam = TEAM_BLUE
   }
   emessage_begin(MSG_BROADCAST, gMsg_TeamScore)
   ewrite_string(g_szHLTeams[id])
   ewrite_short(++g_iScore[iTeam])
   ewrite_short(0)
   emessage_end()
}

almost we done this is the final code .

Код:
#include <amxmodx>
#include <amxmisc>

#define PLUGIN "Set Team Scores"
#define VERSION "0.01"
#define AUTHOR "TuTorial"

enum
{
TEAM_NONE = 0, // This is NULL Team and always = 0
TEAM_RED,        // This is Red Team = 1
TEAM_BLUE,       // This is Blue Team = 2
TEAM_SPEC       // This is Spectator = 3
}

new const g_szHLTeams[][] =
{
"",                // Also like the first one this is NULL but this is a Sting
"scientist",     // my red team name
"hgrunt",        // my blue team name
"SPECTATOR"  //this is spectator as you know .
}

new gMsg_TeamScore
new g_iScore[3]

public plugin_init() {
   register_plugin(PLUGIN, VERSION, AUTHOR)
   gMsg_TeamScore = get_user_msgid("TeamScore")
   register_message(gMsg_TeamScore, "msg_teamScore")
   register_clcmd("say add", "Function") // Lets make this command to run your Function that will set team scores
   
}



public Function(id)
{
   new iTeam = get_user_team(id)
   switch(iTeam)
   {
      case 1: iTeam = TEAM_RED
      case 2: iTeam = TEAM_BLUE
   }
   emessage_begin(MSG_BROADCAST, gMsg_TeamScore) // Send message
   ewrite_string(g_szHLTeams[id]) //Check string names for teams
   ewrite_short(++g_iScore[iTeam]) // Rewrite Scores
   ewrite_short(0)                        //This is Deaths i think we dont need to set this
   emessage_end()
}

public msg_teamScore()
{
   static szTeam[32]
   
   get_msg_arg_string(1, szTeam, 1)
   
   switch(szTeam[0])
   {
      case 1: set_msg_arg_int(2, ARG_SHORT, g_iScore[TEAM_RED]) //This is msg for Red team will send this scores  that you added with your Function
      case 2: set_msg_arg_int(2, ARG_SHORT, g_iScore[TEAM_BLUE]) // The same
   }
}


i hop you understand what i am explaining here

_________________
Charsmax


Вернуться к началу
 Профиль 
  
 Заголовок сообщения: Re: [TUT] Set Team Scores method
СообщениеДобавлено: 04 май 2016, 00:34 
Не в сети
Аватара пользователя
Зарегистрирован:
22 окт 2014, 19:26
Последнее посещение:
20 мар 2024, 19:47
Сообщения: 1018
i think here problem ?


Вложения:
Capture.PNG
Capture.PNG [ 264.58 КБ | Просмотров: 7301 ]

_________________
https://vk.com/kgbaghl
Вернуться к началу
 Профиль 
  
 Заголовок сообщения: Re: [TUT] Set Team Scores method
СообщениеДобавлено: 04 май 2016, 02:10 
Не в сети
Site Admin
Зарегистрирован:
01 июн 2010, 01:27
Последнее посещение:
26 мар 2024, 21:42
Сообщения: 6864
Kuma77 писал(а):
public Function(id)
I recommend to give meaning names to the functions same as for variables.


Вернуться к началу
 Профиль 
  
 Заголовок сообщения: Re: [TUT] Set Team Scores method
СообщениеДобавлено: 04 май 2016, 06:16 
Не в сети
Site Admin
Зарегистрирован:
01 июн 2010, 01:27
Последнее посещение:
26 мар 2024, 21:42
Сообщения: 6864
Kuma77
Код:
register_message(gMsg_TeamScore, "msg_teamScore")
will not work because hl.dll do not sends this message.
Actually this tutorial has drawbacks. I suggest you to rewrite it so: write a plugin that fully manage team scores based on players frags, i.e.
- it will have a function that will increase (and possibly decrease) team frags (decision function)
- send team frags on connect
- send team frags on change
- read team names from mp_teamlist
- read mp_teamplay cvar
Yes, it tends to be more a plugin than a TUT, but managing team scores require all these steps. And still decision function should be written by a coder based on gameplay needs so possibly this will be the best way.


Вернуться к началу
 Профиль 
  
Показать сообщения за:  Поле сортировки  
Начать новую тему Ответить на тему  [ Сообщений: 4 ] 

Часовой пояс: UTC + 5 часов [ Летнее время ]


Кто сейчас на конференции

Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 1


Вы не можете начинать темы
Вы не можете отвечать на сообщения
Вы не можете редактировать свои сообщения
Вы не можете удалять свои сообщения
Вы не можете добавлять вложения

Найти:
Перейти:  
Создано на основе phpBB® Forum Software © phpBB Group
Русская поддержка phpBB