Raised This Month: $ Target: $400
 0% 

Need help on this plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
MajeStik
Member
Join Date: Jun 2009
Old 06-22-2009 , 13:51   Need help on this plugin
Reply With Quote #1

edit

Last edited by MajeStik; 06-16-2010 at 05:34.
MajeStik is offline
MajeStik
Member
Join Date: Jun 2009
Old 06-23-2009 , 02:40   Re: Need help on this plugin
Reply With Quote #2

Nobody ?
MajeStik is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-23-2009 , 18:29   Re: Need help on this plugin
Reply With Quote #3

Wow, that code is jacked up lol. Somebody doesn't know how to use braces .

Here ya go:

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>

#pragma semicolon 1

#define PLUGIN    "Invision War"
#define VERSION    "3.0"
#define AUTHOR    "Cyber-Zone"

#define CHANGE        0        // if 1 -> change nicks when tags not defined by .tag
#define FIRSTTEAM    "Team A"    // Tag #1 If .tag not set
#define SECONDTEAM    "Team B"    // Tag #2 If .tag not set

new g_pauser=0;
new 
bool:g_paused=false;
new 
bool:g_started;
new 
bool:g_exec;
new 
g_score_ct[2];
new 
g_score_t[2];
new 
g_half;
new 
cvar_pausecvar_unpause;

new 
bool:g_changetags[2]= {
    
true,
    
true
};

new 
g_tags[2][65]= {
    
"",
    
""
};

new const 
g_cmds[][]= {
    
"kick",
    
"ban",
    
"banip",
    
"ff",
    
"demo",
    
"ready",
    
"restart",
    
"stop",
    
"map",
    
"tag",
    
"cancel",
    
"warmup",
    
"pause",
    
"unpause"
};

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR);
    
/*
    gp_pause_access 0
        all users
    gp_pause_access 1
        admins
    gp_unpause_access 0
        admins
    gp_unpause_access 1
        admins and player who paused
    */
    
cvar_pause=register_cvar("gp_pause_access","1");
    
cvar_unpause=register_cvar("gp_unpause_access","1");
    
register_concmd("amx_tagt",    "tagChange"ADMIN_KICK"<T tagname>");
    
register_concmd("amx_tagct",    "tagChange"ADMIN_KICK"<CT tagname>");
    
register_clcmd("chooseteam","changeTeam");
    
register_clcmd("say""chatFilter"ADMIN_KICK);
    
register_clcmd("say !score","showScore");
    
register_event("TeamScore""teamScore""a");
    
server_cmd("pausable 0");
    
register_concmd(".replaceme","replaceme_cmd");
    
register_concmd(".replace","replace_cmd",ADMIN_RCON,"Porneste inlocuirea jucatorilor");
}
public 
changeTeam(id)
{
    if(
g_started)
    {
        
client_print(idprint_chat,"<Invision War> Nu poti schimba echipa in timpul meciului !");
        return 
PLUGIN_HANDLED;
    }
    return 
PLUGIN_CONTINUE;
}
public 
chatFilter(id) {
    new 
message[128];
    
read_argv(1message127);
    for(new 
i=0;i<sizeof(g_cmds);i++) {
        new 
cmd[33];
        
formatex(cmd,32,"!%s",g_cmds[i]);
        if(
containi(message,cmd) == 0) {
                
//admin level required
                
switch(i) {
                case 
0,1,2,3,4,5,6,7,8,9,10,11:    {
                    if(!(
get_user_flags(id) & ADMIN_KICK))
                        return 
PLUGIN_CONTINUE;
                    }
                }
                
callBack(id,i);
                return 
PLUGIN_HANDLED;
        }
    }
    return 
PLUGIN_CONTINUE;
}

public 
showMatchEnd() {
    switch( 
g_half ) {
        case 
1: {
            
server_cmd("say Prima repriza s-a terminat !");
            
showScore2(1);
            
server_cmd("say Incarc setarile pentru repriza a 2-a... !");
            
server_cmd("say Setari incarcate cu succes !");
{
    
set_hudmessage(255255255, -1.00.206.03.0);
    
show_hudmessage(0"Schimba echipa acum !");
}
            
server_cmd("say SCHIMBATI ECHIPELE ACUM !");
        }
        case 
2: {
            
server_cmd("say Meciul s-a terminat !.");
            
showScore2(2);
            
server_cmd("say Multumim pentru participare !");
{
    
set_hudmessage(255255255, -1.00.206.03.0);
    
show_hudmessage(0"Meciul s-a terminat !");
}
            
server_cmd("say Invision War 3.0 by MajeStik");
               
server_cmd("amx_nopass");
               
server_cmd("mp_friendlyfire 0");
               
server_cmd("mp_freezetime 0");
               
server_cmd("mp_roundtime 3");
            
prepareMatch();
        }
    }
    
g_exec=false;
}

prepareMatch() {
    
//game not started
    
g_started false;
    
g_half    0;
    
    
//reset score
    
g_score_ct[0]    = 0;
    
g_score_ct[1]    = 0;
    
g_score_t[0]    = 0;
    
g_score_t[1]    = 0;
    
    
//clear tags
    
g_changetags[0]    = true;
    
g_changetags[1]    = true;
    
g_tags[0]    = "";
    
g_tags[1]    = "";
}

public 
restartRound(arg[]) {
    new 
id arg[0];
    new 
args[1];
    
args[0]    = id+1;
    
g_exec    true;
    switch( 
id ) {
        case 
0: {
            
server_cmd("mp_friendlyfire 1");
              
server_cmd("mp_roundtime 1.75");
               
server_cmd("mp_freezetime 10");
               
server_cmd("mp_limitteams 0");
               
server_cmd("mp_autoteambalance 0");
               
server_cmd("mp_timelimit 0");
               
server_cmd("mp_autokill 0");
               
server_cmd("mp_buytime 0.25");
               
server_cmd("mp_startmoney 800");
            
server_cmd("say Incarc setarile Invision War...");
            
server_cmd("say Setari incarcate cu succes !");
{
    
set_hudmessage(255255255, -1.00.206.03.0);
    
show_hudmessage(0"Incepem...");
}
            
server_cmd("say Meciul incepe in:");
            
server_cmd("say 5");
        }
        case 
1,2: {
            
server_cmd("say %d",5-id);
            
server_cmd("sv_restartround 0");
        }
        case 
3server_cmd("say 2");
        case 
4: {
            
server_cmd("say 1");
            
server_cmd("sv_restartround 1");
            
set_task(2.0"restartRound"0args,1);
        }
        case 
5: {
            
server_cmd("say Game is ON !");
            
server_cmd("say LIVE LIVE LIVE LIVE");
            
server_cmd("say GL & HF !");
            
set_hudmessage(255255255, -1.00.206.03.0);
            
show_hudmessage(0"LIVE ! LIVE ! LIVE ! LIVE !",g_half); 
            
g_exec=false;
        }
    }
    if(
id 4)
        
set_task(1.0"restartRound"0args,1);
}

public 
callBack(idcID) {
    new 
message[128], cmd[33], arg[65], arg2[65];
    
read_argv (1message128);
    
parse(message,cmd,32,arg,64,arg2,64);
    
replace(cmd,32,".","");
    
    switch(
cID) {
        case 
0: { // Kick Player
            
console_cmd(id,"amx_kick %s"arg);
        }
        case 
1: { // Ban Player
            
new bantime=str_to_num(arg2);
            if(
bantime==0)
                
bantime=1;
            
console_cmd(id,"amx_ban %s %d"argbantime);
        }
        case 
2: { // BanIP Player
            
new bantime=str_to_num(arg2);
            if(
bantime==0)
                
bantime=1;
            
console_cmd(id,"amx_banip %s %d"argbantime);
        }
        case 
3: { // Set FriendlyFire
            
if(equali(arg,"on")) {
                
console_cmd(id,"amx_cvar mp_friendlyfire 1");
            }
            else if(
equali(arg,"off")) {
                
console_cmd(id,"amx_cvar mp_friendlyfire 0");
            }
        }
        case 
4: { // Record Demo
            
new demoname[71];
            new 
datetime[31],mapname[21];
            
get_time("%d-%m-%Y-%H-%M-%S"datetime30);
            
get_mapname(mapname,20);
            
formatex(demoname,70,"demo-%s-%s.dem",mapname,datetime);
            new 
player cmd_target(idarg0);
            if(
player==0)
                
client_print(id,print_chat,"<Invision Demo> '%s' nu exista !",arg);
            else {
                
console_cmd(player,"record %s",demoname);
                new 
name[36];
                
get_user_name(player,name,35);
                
client_print(id,print_chat,"<Invision Demo> Inregistrez [demo] pe %s",name);
            }
        }
        case 
5: { // Start Match
            
if(g_half==&& !g_started) {
                
client_print(idprint_chat,"<Invision War> Nu poti porni o a 3-a parte");
                return 
PLUGIN_HANDLED;
            }
            if(
g_exec) {
                
client_print(idprint_chat,"<Invision War> Loading...");
                return 
PLUGIN_HANDLED;
            }
            if(
g_started) {
                
client_print(idprint_chat,"<Invision War> Meciul este in derulare.Tasteaza .stop inainte !");
                return 
PLUGIN_HANDLED;
            }
            if(
equal(g_tags[0],"") && g_changetags[0]) {
                
copy(g_tags[0], 20 ,FIRSTTEAM);
                
g_changetags[0]=false;
            }
            if(
equal(g_tags[1],"")&& g_changetags[1]) {
                
copy(g_tags[1], 20 ,SECONDTEAM);
                
g_changetags[1]=false;
            }
            
            
// Exec configs & set bools.
            
server_cmd("exec war.cfg");
            
checkAll();
            new 
args[1];
            
args[0]=0;
            
restartRound(args);
            if(
g_half==0)
                
g_half=1;
            else if(
g_half==1)
                
g_half=2;
            
            
g_started=true;
        }
        case 
6: { // Restart
            
if(g_exec) {
                
client_print(idprint_chat,"<Invision War> Loading...");
                return 
PLUGIN_HANDLED;
            }
            if(!
g_started) {
                
client_print(idprint_chat,"<Invision War> Nici un meci in derulare.Tasteaza .start pentru a incepe");
                return 
PLUGIN_HANDLED;
            }
            
            new 
args[1];
            
args[0] = 0;
            
restartRound(args);
            
g_score_ct[g_half-1]    = 0;
            
g_score_t[g_half-1]    = 0;
            
g_started        true;
        }    
        case 
7: { // Stop match.
            
if(g_exec)
            {
                
client_print(idprint_chat,"<Invision War> Loading...");
                return 
PLUGIN_HANDLED;
            }
            if(!
g_started)
            {
                
client_print(idprint_chat,"<Invision War> Nici un meci in derulare.Tasteaza .start pentru a incepe");
                return 
PLUGIN_HANDLED;
            }
            
            
g_exec true;
            
server_cmd("exec warmup.cfg");
            
server_cmd("sv_restartround 3");
            
set_task(4.0,"showMatchEnd");
            
g_started false;
        }
        case 
8: { // Changelevel
            
console_cmd(id,"amx_map %s"arg);
        }
        case 
9: { // Tag System
            
if(!(g_half==|| (g_half==&& !g_started))) {
                
client_print(idprint_chat,"<Invision Tags> Nu poti modifica acum");
                return 
PLUGIN_HANDLED;
            }
            
            if(
equali(arg"OFF")) {
                new 
ct[21],t[21];
                if(
g_half == || g_half == 1) {
                    
copy(ct ,20g_tags[0]);
                    
copy(,20g_tags[1]);
                }
                else if(
g_half == 2) {
                    
copy(ct ,20g_tags[1]);
                    
copy(,20g_tags[0]);
                }
                
untagThem(CS_TEAM_CTct);
                
untagThem(CS_TEAM_Tt);
                
g_tags[0]="";
                
g_tags[1]="";
            }
            else if(
equal(arg,"") || equal(arg2,"")) {
                
client_print(id,print_chat,"Current tags:");
                
client_print(id,print_chat,"^tCT: %s",g_tags[0]);
                
client_print(id,print_chat,"^tT : %s",g_tags[1]);
                
client_print(id,print_chat,"Using: .tag CT|T <tag> or .tag OFF");
            }
            else if(
equali(arg,"CT")) {
                
client_cmd(id,"amx_tagct %s"arg2);
            }
            else if(
equali(arg,"T")) {
                
client_cmd(id,"amx_tagt %s"arg2);
            }
            else if(
equali(arg,"sCT")) {
                new 
a;
                if(
g_half == || g_half == 1) {
                    
a=0;
                }
                else if(
g_half == 2) {
                    
a=1;
                }
                
g_tags[a]=arg2;
                
g_changetags[a]=false;
                
                
client_cmd(id,"say .tag");
            }
            else if(
equali(arg,"sT")) {
                new 
a;
                if(
g_half == || g_half == 1) {
                    
a=1;
                }
                else if(
g_half == 2) {
                    
a=0;
                }
                
g_tags[a]=arg2;
                
g_changetags[a]=false;
                
g_changetags[0]=true;
                
client_cmd(id,"say .tag");
            }
            else {
                
client_print(id,print_chat,"Using: .tag CT|T <tag> or .tag OFF");
            }
            
        }
        case 
10: { // Cancel Game.
            
if(g_half == 0) {
                
client_print(idprint_chat,"<Invision War> Nici un meci in desfasurare");
                return 
PLUGIN_HANDLED;
            }
            
            
prepareMatch();
            
server_cmd("say !! Game cancelled !!");
            
server_cmd("say !! Game cancelled !!");
            
server_cmd("sv_restartround 3");
        }
        case 
11: {//Warmup
               
server_cmd("sv_restart 1");
               
server_cmd("mp_friendlyfire 0");
               
server_cmd("mp_freezetime 0");
               
server_cmd("mp_roundtime 3");
               
server_cmd("mp_buytime 3");
               
server_cmd("mp_startmoney 16000");
            
server_cmd("exec warmup.cfg");
            
server_cmd("say Runde de incalzire !");
            
server_cmd("say Incarc setarile Invision Warmup...");
            
server_cmd("say Setari incarcate cu succes");
{
    
set_hudmessage(255255255, -1.00.206.03.0);
    
show_hudmessage(0"Warmup Rounds !");
}    
        }
        case 
12: {//pause
            
if(g_paused)
            {
                
client_print(id,print_chat,"<Invision Pause> Este deja Pauza.");
            }
            else
                
pause_server(id);
        }
        case 
13: {//unpause
            
if(!g_paused)
            {
                
client_print(id,print_chat,"<Invision Pause> Nu este Pauza.");
            }
            else
                
pause_server(id);
        }
    }
    return 
PLUGIN_HANDLED;
}

public 
showScore(id) {
    if(
g_half == 0)
        
client_print(idprint_chat,"<Invision War> Scorul va fi afisat in timpul meciului");
    else
        
client_print(idprint_chat,"<Invision Score> %s %d:%d %s",g_tags[0],g_score_ct[0]+g_score_ct[1], g_score_t[0]+g_score_t[1],g_tags[1]);
    
    return 
PLUGIN_HANDLED;
}
public 
showScore2(type) {
    if(
g_half == 0)
        
server_cmd("say Scorul va fi afisat in timpul meciului");
    else{
        new 
comment[50]="";
        if(
type==1)
            
copy(comment,49," Scorul este:");
        else if(
type==2)
            
copy(comment,49," Scor final:");
        
server_cmd("say %s [%s] %d:%d [%s]",comment,g_tags[0],g_score_ct[0]+g_score_ct[1], g_score_t[0]+g_score_t[1],g_tags[1]);
    }
    return 
PLUGIN_HANDLED;
}

public 
teamScore() {
    if(!
g_started)
        return 
PLUGIN_CONTINUE;
    new 
team[32];
    
read_data(1team31);
    if (
g_half == 1) { // first half
        
if (team[0] == 'C')
            
g_score_ct[0] = read_data(2);
        else if (
team[0] == 'T')
            
g_score_t[0] = read_data(2);    
    }
    else if (
g_half == 2) { // second half
        
if (team[0] == 'C')
            
g_score_t[1] = read_data(2);
        else if (
team[0] == 'T')
            
g_score_ct[1] = read_data(2);
    }
    return 
PLUGIN_CONTINUE;
}

public 
tagChange(id,level,cid) {
    if (!
cmd_access(id,level,cid,1))
        return 
PLUGIN_HANDLED;
    
    new 
cmd[11], tag[21];
    
read_argv (0cmd10);
    
read_argv (1tag20);
    if(
equali("amx_tagt",cmd)) {
        
setGTags(1,tag);
        
tagThem(CS_TEAM_T);
    }
    else if(
equali("amx_tagct",cmd)) {
        
setGTags(2tag);
        
tagThem(CS_TEAM_CT);
    }
    return 
PLUGIN_HANDLED;
}

public 
tagPlayer(id) {
    new 
CsTeams:p_team=cs_get_user_team(id);
    new 
name[36];
    
get_user_name(id,name,35);
    new 
tag[21];
    new 
0;
    if(
g_half==|| (g_half==&& g_started)) {
        if(
p_team==CS_TEAM_CT)
            
a=0;
        else if(
p_team==CS_TEAM_T)
            
a=1;
    }
    else if(
g_half==|| (g_half==&& !g_started)) {
        if(
p_team==CS_TEAM_CT)
            
a=1;
        else if(
p_team==CS_TEAM_T)
            
a=0;
    }
    if(!
g_changetags[a] && CHANGE==0)
        return;
    
copy(tag ,20g_tags[a]);
    if(
contain(name,tag)!=0)
        
client_cmd(id"name ^"%s%s^"",tag,name);
}

tagThem(CsTeams:team) {
    new 
Players[32], playerCountplayer;
    
get_players(PlayersplayerCount);
    for (new 
i=0i<playerCounti++) {
        
player Players[i]; 
        new 
CsTeams:p_team=cs_get_user_team(player);
        if(
p_team == team) {
            
tagPlayer(player);
        }
    }
}

untagThem(CsTeams:teamtag[21]) {
    new 
Players[32], playerCountiplayer;
    
get_players(PlayersplayerCount);
    for (
i=0i<playerCounti++) {
        
player Players[i]; 
        new 
CsTeams:p_team=cs_get_user_team(player);
        new 
name[36];
        
get_user_name(player,name,35);
        if(
p_team == team) {
            if(
contain(name,tag)==0) {
                
replace(name35tag,"");
                
client_cmd(player,"name ^"%s^"",name);
            }
        }
    }
    new 
type=0;
    if(
team==CS_TEAM_T)
        
type=1;
    else if(
team==CS_TEAM_CT)
        
type=2;
    
setGTags(type"");
}

setGTags(typetag[21]) {
    if(
g_half==|| g_half==1) {
        switch( 
type ) {
            case 
1copy(g_tags[1],64,tag);
            case 
2copy(g_tags[0],64,tag);
        }
    }
    if(
g_half==2) {
        switch( 
type ) {
            case 
1copy(g_tags[0],64,tag);
            case 
2copy(g_tags[1],64,tag);
        }
    }
}

public 
client_infochanged(id) {
    if(
equal(g_tags[0],"") || equal(g_tags[1],""))
        return;

    
set_task(1.0"tagPlayer",id);
}

public 
pause_server(id) {
    new 
p_acess=get_pcvar_num(cvar_pause);
    new 
up_acess=get_pcvar_num(cvar_unpause);
    if(
g_paused)
    {
        if
        ((
up_acess==&& access(id,ADMIN_BAN))
        || (
up_acess==&& (access(id,ADMIN_BAN) || id==g_pauser)))
        {
            
g_pauser=0;
            
server_cmd("say Server Unpaused");
        }
        else
        {
            
client_print(idprint_chat,"<Invision Pause> Nu poti folosi acum");
            return;
        }
    }
    else
    {
        if
        ((
p_acess==0) || (p_acess==&& access(id,ADMIN_BAN)))
        {
            
g_pauser=id;
            
server_cmd("say Server Paused");
        }
        else
        {
            
client_print(idprint_chat,"<Invision Pause> Nu poti folosi acum");
            return;
        }
    }
    new 
name[36];
    
get_user_name(id,name,35);
    
server_cmd("say %s paused/unpaused game",name);
    
server_cmd("amx_pause");
    
g_paused=!g_paused;
}

public 
checkAll() {
    
tagThem(CS_TEAM_CT);
    
tagThem(CS_TEAM_T);
}

public 
replaceme_cmd(id)
{
    new 
players[32],name[32],num,index,i;
    
get_players(players,num);
    
get_user_name(id,name,31);
    for(
0;num;i++)
    {
        
index players[i];
        if(!(
get_user_flags(index) & ADMIN_RCON))
            continue;
        
client_print(index,print_chat,"Jucatorul %s cere permisiunea de a iesi de la meci.Daca esti de acord scrie .replace %s",name,name);    
    }
    return 
PLUGIN_HANDLED;
}
public 
replace_cmd(id,level,cid)
{
    if(!
cmd_access(id,level,cid,2))
        return 
PLUGIN_HANDLED;
    new 
arg[32]; read_argv(1,arg,31);
    new 
target cmd_target(id,arg,9);
    if(!
target)
        return 
PLUGIN_HANDLED;
    
client_print(target,print_chat,"Adminul la fost de acord cu cererea ta. Iti cauta inlocuitor , asteapta ...");
    
client_print(0,print_chat,"Console: Adminul cauta jucator-inlocuitor ...");
    
set_hudmessage(2552552550.020.2506.05.0);
    
show_hudmessage(target"Nu iesi de pe server inainte de a intra^n jucatorul-inlocuitor^nAdminul iti va da kick cand jucatorul^n va intra pe server");
    return 
PLUGIN_HANDLED;

__________________
fysiks is offline
MajeStik
Member
Join Date: Jun 2009
Old 06-23-2009 , 18:56   Re: Need help on this plugin
Reply With Quote #4

Thx but i have another problem I activated the tags.Whe I joined on CT my nick changed in a.MajeStik.When I change the team my nick changed in b.a.MajeStik.I want to remain the first tag and after the match end to reset the tags.I want tags to be activated at the match start
MajeStik is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-23-2009 , 19:06   Re: Need help on this plugin
Reply With Quote #5

I only did what I did cause it was easy. I won't do anything more complicated since it's a CS specific plugin.
__________________
fysiks is offline
MajeStik
Member
Join Date: Jun 2009
Old 06-24-2009 , 04:18   Re: Need help on this plugin
Reply With Quote #6

Ok.Thx anyway
Edit : There is a problem..The !replace & !replaceme command work only in console..Can you make this to work in chat ?

Last edited by MajeStik; 06-24-2009 at 05:13.
MajeStik is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-24-2009 , 19:03   Re: Need help on this plugin
Reply With Quote #7

Quote:
Originally Posted by MajeStik View Post
Ok.Thx anyway
Edit : There is a problem..The !replace & !replaceme command work only in console..Can you make this to work in chat ?
I don't know why "!replace" would work at all as the actual command is ".replace" lol .

If you use them in chat, they have to be handled differently than the way they are now. So, they would need a whole new function. I don't think I will do that .
__________________
fysiks is offline
MajeStik
Member
Join Date: Jun 2009
Old 06-25-2009 , 04:02   Re: Need help on this plugin
Reply With Quote #8

Ok.But can you help me with this ?

" Thx but i have another problem I activated the tags.Whe I joined on CT my nick changed in a.MajeStik.When I change the team my nick changed in b.a.MajeStik.I want to remain the first tag and after the match end to reset the tags.I want tags to be activated at the match start"

MajeStik is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 15:27.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode