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