nich mekern meine ersten versuche gg
hab mal versucht ne abfrage und variable mehr einzubauen um soundcheck zusätslich mit zu aktivieren fals es im public nicht läuft
habs gerade auf arbeit gemacht wo ich nciht testen kann sagt doch mal was ihr davon haltet
compilieren lässt sich das ganze ohne warnings und errors
Code:
/* [WING]Sir Drink a lot's & [WING]Black Knight's CW-Creator 09.05.2003 */
#pragma dynamic 8192
#include <core>
#include <console>
#include <string>
#include <admin>
#include <adminlib>
#define ACCESS_WAR 256
#define MAX_IP_LENGTH 22
new STRING_VERSION[MAX_DATA_LENGTH] = "2.0 beta RC1";
new warpluginini[MAX_DATA_LENGTH]="addons/adminmod/config/cwcreator/warplugin.ini";
new warcfg[MAX_DATA_LENGTH]="addons/adminmod/config/cwcreator/war.cfg";
new ruledir[MAX_DATA_LENGTH]="addons/adminmod/config/cwcreator/rules/";
new cwmcf[MAX_DATA_LENGTH]="addons/adminmod/config/cwcreator/cwmapcycle.txt";
new settings[MAX_DATA_LENGTH]="addons/adminmod/config/cwcreator/settings.ini";
new cvar[14][MAX_DATA_LENGTH]={"test","[WING]","de_aztec","de_dust","de_dust","esl.cfg","0","0","all","0","","0","",""};
new round=0;
new maxrounds;
new timelimit;
/******************************** WAR-SETTINGS ***************************************/
public admin_war_set(HLCommand,HLData,HLUserName,UserIndex) {
new Command[MAX_COMMAND_LENGTH];
new User[MAX_NAME_LENGTH];
new maxplayers = maxplayercount();
new Target[MAX_NAME_LENGTH];
new i;
new SessionID;
new WONID;
new Team;
new execrule[MAX_TEXT_LENGTH]="exec ";
new apf[MAX_DATA_LENGTH]="admin_plugin_file ";
new mcf[MAX_DATA_LENGTH]="mapcyclefile ";
new Text[MAX_TEXT_LENGTH]="sv_password ";
if(strmatch(cvar[11],"0",MAX_DATA_LENGTH)) {
for(i=0;i<=9;i++) {
/*-------- ÜBERPRÜFUNG, OB ALLE DATEN ANGEGEBEN WURDEN ------*/
if(strlen(cvar[i])==0){
selfmessage("Angaben unvollstaendig!");
listprop();
return PLUGIN_HANDLED;
}
}
convert_string(HLData,cvar[9],MAX_DATA_LENGTH);
if(strlen(cvar[10]) > 20) {
selfmessage("Der Clantag ist zu lang!!");
selfmessage("Bitte kuerzen");
return PLUGIN_HANDLED;
}
if(strlen(cvar[10]) == 0) {
strcpy(cvar[10],"Gast",MAX_DATA_LENGTH);
}
writefile(settings,cvar[10],10);
/*-------- ALLE LEUTE OHNE CLANTAG WERDEN GEKICKT UND BEI REST WIRD PASSWORT GESETZT ------*/
if(strlen(cvar[10])!=0){
new hltvip[MAX_TEXT_LENGTH];
new ui;
new freeslots=0;
get_vaultdata("hltv_ip",hltvip,MAX_TEXT_LENGTH);
if(strlen(hltvip)!=0){
ui=hltvonline();
if(ui>0){
new sIP[MAX_IP_LENGTH];
new sMatchIP[MAX_IP_LENGTH];
new sPort[6];
playerinfo(i,Target,MAX_NAME_LENGTH,SessionID,WONID,Team);
get_userIP(Target,sIP,MAX_IP_LENGTH);
strsplit(hltvip,":",sMatchIP,MAX_IP_LENGTH,sPort,6);
if(streq(sMatchIP,sIP)){
new hltvinfo[MAX_NAME_LENGTH];
get_userinfo(Target,"hltv_slots",hltvinfo,MAX_NAME_LENGTH);
freeslots=strtonum(hltvinfo);
get_userinfo(Target,"hltv_specs",hltvinfo,MAX_NAME_LENGTH);
freeslots-=strtonum(hltvinfo);
snprintf(hltvip,MAX_TEXT_LENGTH,"connect %s",hltvip);
}
}
}
for(i=1; i<=maxplayers; i++) {
if(playerinfo(i,Target,MAX_NAME_LENGTH,SessionID,WONID,Team)==1) {
if (strstr(Target,cvar[1]) == -1 && strstr(Target,cvar[10]) == -1 && Team != TEAM_PROXY) {
if(check_immunity(Target)==0 && i != UserIndex) {
if(freeslots>0){
message(Target, "Sorry, CW! Du wirst auf den HLTV umgeleitet.");
execclient(Target,hltvip);
}
else{
message(Target, "Sorry, CW! Aber danke fuer das schnelle Disconnecten. ;p");
kick(Target);
}
}
}
}
}
}
/*-------- In die war.cfg wird die angegebene Regeln.cfg als Exec reingeschrieben ------*/
strcat(apf,warpluginini,MAX_DATA_LENGTH);
writefile(warcfg,apf,-1);
snprintf(execrule,MAX_DATA_LENGTH,"exec %s%s",ruledir,cvar[5]);
writefile(warcfg,execrule,-1);
writefile(warcfg,"vote_freq 1",-1);
writefile(warcfg,"admin_vote_echo 1",-1);
writefile(warcfg,"admin_vote_autostart 0",-1);
writefile(warcfg,"amv_vote_duration 15",-1);
writefile(warcfg,"admin_cs_restrict 0",-1);
writefile(warcfg,"admin_repeat_freq 0",-1);
/*-------- Soundcheck aktivieren fals gesetzt --------*/
if(strlen(cvar[9]) == 1) {
exec ("meta load addons/soundcheck/dlls/soundcheck_mm.dll");
}
/*-------- PASSWORT SETZEN UND MAPCHANGE DURCHFÜHREN ------
Sperre, damit man nicht das ursprüngliche Server-Passwort
mit dem neu gesetzten Passwort, durch zweimal Aufrufen des
admin_warsettings,überschreibt.*/
getstrvar("sv_password",cvar[11],MAX_TEXT_LENGTH);
writefile(settings,cvar[12],13);
getstrvar("mapcyclefile",cvar[12],MAX_TEXT_LENGTH);
writefile(settings,cvar[13],14);
strcat(Text,cvar[0],MAX_TEXT_LENGTH);
exec(Text);
snprintf(Text,MAX_TEXT_LENGTH,"Das Passwort ist jetzt ^"%s^". ^n Nextmap %s",cvar[0],cvar[2]);
for(i=1; i<=maxplayers; i++) {
if(playerinfo(i,Target,MAX_NAME_LENGTH,SessionID,WONID,Team)==1) {
if(Team!=TEAM_PROXY) {
messageex(Target,Text,print_pretty);
}
}
}
selfmessage(Text);
convert_string(HLCommand,Command,MAX_COMMAND_LENGTH);
convert_string(HLUserName,User,MAX_NAME_LENGTH);
say_command(User,Command,cvar[10]);
set_vaultnumdata("admin_war_on",1);
/*------------- Mapcyclefile anlegen -----------------*/
strcat(mcf,cwmcf,MAX_DATA_LENGTH);
writefile(warcfg,mcf,-1);
resetfile(cwmcf);
writefile(cwmcf,cvar[2],-1);
writefile(cwmcf,cvar[3],-1);
writefile(cwmcf,cvar[3],-1);
writefile(settings,"0",12);
set_vaultnumdata("admin_war_rs",1);
set_timer("mapchange",13,0,cvar[2]);
return PLUGIN_HANDLED;
}
selfmessage("In der settings.ini ist bereits ein Passwort gesetzt.");
selfmessage("Bitte admin_war_end ausfuehren, um diese Einstellungen zu loeschen.");
selfmessage("Danach admin_war_set erneut aufrufen.");
return PLUGIN_HANDLED;
}
public mapchange(Timer,Repeat,HLUser,HLParam) {
new Map[MAX_NAME_LENGTH];
convert_string(HLParam,Map,MAX_NAME_LENGTH);
changelevel(Map,1);
return PLUGIN_CONTINUE;
}
/********************************************************************************/
/********************************** CW - START **********************************/
public admin_war_start(HLCommand,HLData,HLUserName,UserIndex) {
new Text[MAX_TEXT_LENGTH]="Wenn alle die Frage,'Seid Ihr bereit' mit JA beantworten,^nkommt 2 mal Restartround, und es geht los.";
new hltv;
new dummy[10];
new hltvname[MAX_NAME_LENGTH];
new on;
get_vaultnumdata("admin_war_on",on);
if(on==0) {
selfmessage("Sorry, Befehl nur im Warmodus durchfuehrbar!");
return PLUGIN_HANDLED;
}
if (strlen(cvar[10]) != 0 && round == 1) {
snprintf(Text,MAX_TEXT_LENGTH,"Wir begruessen den Clan %s zum heutigen Clanwar^nWenn alle die Frage,'Seid Ihr bereit' mit JA beantworten,^nkommt 2 mal Restartround, und es geht los.",cvar[10]);
}
centersay(Text,30,68,255,125);
vote("Seid ihr bereit?","Ja","Nein","HandleWarVote",dummy);
hltv=hltvonline();
if(hltv!=0){
playerinfo(hltv,hltvname,MAX_NAME_LENGTH);
messageex(hltvname,"Startvote begonnen",print_tty);
}
return PLUGIN_HANDLED;
}
public HandleWarVote(WinningOption,HLMap,VoteCount,UserCount) {
new VoteMap[MAX_DATA_LENGTH];
new a=0;
a=hltvonline();
if(a!=0){
a=1;
}
convert_string(HLMap,VoteMap,MAX_DATA_LENGTH);
if (WinningOption == 1 && VoteCount >= (UserCount-a)) {
centersay("Gut. Alle sind bereit.^nDann kann es ja nach 2 mal Restart Round losgehen.",10,68,255,125);
restarttimers();
if(fileexists("addons/adminmod/config/cwcreator/startwar.cfg")){
exec("exec addons/adminmod/config/cwcreator/startwar.cfg");
}
return PLUGIN_CONTINUE;
}
else {
centersay("Es haben leider nicht alle mit JA geantwortet.^nEs muessen alle mit JA abstimmen,^n um den CW zu starten.",10,255,40,44);
}
return PLUGIN_CONTINUE;
}
public admin_war_restart(HLCommand,HLData,HLUserName,UserIndex) {
restarttimers();
centersay("Nach 2 mal Restart Round geht es los.",10,68,255,125);
return PLUGIN_HANDLED;
}
restarttimers(){
new on;
get_vaultnumdata("admin_war_on",on);
if(on==1) {
set_vaultnumdata("admin_war_rs",1);
set_timer("Restart_Round",10,0);
set_timer("warmup_end",12,0);
set_timer("Restart_Round",13,0);
set_timer("War_Starts",15,0);
}
else{
selfmessage("Sorry, Befehl nur im Warmodus durchfuehrbar!");
}
}
public Restart_Round(Timer,Repeat,HLUser) {
exec("sv_restartround 1");
return PLUGIN_CONTINUE;
}
public warmup_end(Timer,Repeat,HLUser) {
new merk[MAX_TEXT_LENGTH];
snprintf(merk, MAX_TEXT_LENGTH,"mp_timelimit %i",timelimit);
exec(merk);
snprintf(merk, MAX_TEXT_LENGTH,"mp_maxrounds %i",maxrounds);
exec(merk);
if (strmatch(cvar[6],"1",MAX_DATA_LENGTH) || strmatch(cvar[7],"1",MAX_DATA_LENGTH)){
snprintf(merk, MAX_TEXT_LENGTH,"%s %d",cvar[11],maxrounds);
plugin_exec("cwc_addon_start",merk);
}
return PLUGIN_CONTINUE;
}
public War_Starts(Timer,Repeat,HLUser) {
centersay("Und los geht's! ^n Viel Glueck allen Beteiligten!",10,68,255,125);
return PLUGIN_CONTINUE;
}
/********************************************************************************/
/********************************** CW - END ************************************/
public admin_war_end(HLCommand,HLData,HLUserName,UserIndex) {
new Text[MAX_TEXT_LENGTH];
new on;
get_vaultnumdata("admin_war_on",on);
if(on==1){
/*-------- Altes Passwort und alter Mapcycle werden wiederhergestellt ---------*/
readfile(settings,cvar[12],13,MAX_DATA_LENGTH);
readfile(settings,cvar[13],14,MAX_DATA_LENGTH);
if (strlen(cvar[12])==0){
strcpy(cvar[12],"none",MAX_DATA_LENGTH);
}
writefile(settings,"",13);
snprintf(Text,MAX_TEXT_LENGTH,"sv_password %s",cvar[12]);
exec(Text);
snprintf(Text,MAX_TEXT_LENGTH,"mapcyclefile %s",cvar[12]);
exec(Text);
set_vaultnumdata("admin_war_on",0);
if(strlen(cvar[9]) == 1) {
exec ("meta unload soundcheck_mm.dll");
}
/*-------- Die war.cfg wird geleert ---------*/
resetfile(warcfg);
/*-------- Kleines Dankeschön für den War ------------ */
selfmessage("Die normalen Einstellungen werden nach einem Mapchange in 60 s wiederhergestellt.");
centersay("Der War ist beendet.^n Vielen Dank an alle Beteiligten.",10,68,255,125);
set_timer("mapchange",59,0,cvar[4]);
snprintf(Text, MAX_TEXT_LENGTH, "Mapchange auf %s in einer Minute.",cvar[4]);
say(Text);
if (strmatch(cvar[6],"1",MAX_DATA_LENGTH)){
plugin_exec("cwc_addon_end",cvar[11]);
}
strcpy(cvar[11],"0",MAX_DATA_LENGTH);
writefile(settings,"0",12);
if(fileexists("addons/adminmod/config/cwcreator/endwar.cfg")){
exec("exec addons/adminmod/config/cwcreator/endwar.cfg");
}
}
else {
selfmessage("Es laeuft kein War mehr!");
}
return PLUGIN_HANDLED;
}
/*********** HLTV Online-Ueberpruefung *************/
hltvonline() {
new i;
new maxplayers = maxplayercount();
new Target[MAX_NAME_LENGTH];
new SessionID;
new WONID;
new Team;
for(i=1; i<=maxplayers; i++) {
if(playerinfo(i,Target,MAX_NAME_LENGTH,SessionID,WONID,Team)==1) {
if (Team == 600) {
return i;
}
}
}
return 0;
}
/******* Spezifische Mapsettings ueberschreiben *********/
public nomapsets(Timer,Repeat,HLUser) {
new Text[MAX_TEXT_LENGTH];
snprintf(Text,MAX_TEXT_LENGTH,"exec %s",warcfg);
exec(Text);
say("Map-Settings ueberschrieben!");
set_timer("warmup_init",3,0);
return PLUGIN_CONTINUE;
}
/******* Warmup einstellen ***********/
public warmup_init(Timer,Repeat,HLUser) {
timelimit=getvar("mp_timelimit");
maxrounds=getvar("mp_maxrounds");
exec("mp_timelimit 0");
exec("mp_maxrounds 0");
return PLUGIN_CONTINUE;
}
/********* CW Creator settings.ini cvars setzen *************/
listprop(){
new cmd[10][MAX_COMMAND_LENGTH]={"admin_war_pass","admin_war_tag","admin_war_map1","admin_war_map2","admin_war_endmap","admin_war_rules","admin_war_count","admin_war_demo","admin_war_countrules","admin_war_sc"};
new i;
new Text[MAX_TEXT_LENGTH];
selfmessage("CW-Einstellungen:");
for(i=0;i<=9;i++){
snprintf(Text,MAX_TEXT_LENGTH,"%s %s",cmd[i],cvar[i]);
selfmessage(Text);
}
return PLUGIN_CONTINUE;
}
setorinfo(CVar[],Value[]){
new cmd[10][MAX_COMMAND_LENGTH]={"admin_war_pass","admin_war_tag","admin_war_map1","admin_war_map2","admin_war_endmap","admin_war_rules","admin_war_count","admin_war_demo","admin_war_countrules","admin_war_sc"};
new i;
new merk;
if(strlen(Value)!=0){
for(i=0;i<=9;i++){
if(strcasecmp(CVar,cmd[i])==0){
merk=i;
break;
}
}
writefile(settings,Value,merk+1);
strcpy(cvar[merk],Value,MAX_DATA_LENGTH);
}
listprop();
return PLUGIN_CONTINUE;
}
public admin_war_cvar(HLCommand,HLData,HLUserName,UserIndex){
new Value[MAX_DATA_LENGTH];
new CVar[MAX_DATA_LENGTH];
new iNum;
convert_string(HLData,Value,MAX_DATA_LENGTH);
convert_string(HLCommand,CVar,MAX_DATA_LENGTH);
if(strlen(Value)!=0){
if(strcasecmp(CVar,"admin_war_pass")==0){
if (strcmp(Value,"none")== 0) {
selfmessage("Passwort nicht korrekt!");
return PLUGIN_HANDLED;
}
}
else if(strcasecmp(CVar,"admin_war_tag")==0){
if(strlen(Value) > 20) {
selfmessage("Der ClanTag ist zu lang!");
return PLUGIN_HANDLED;
}
}
else if(strcasecmp(CVar,"admin_war_map1")==0 || strcasecmp(CVar,"admin_war_map2")==0 || strcasecmp(CVar,"admin_war_endmap")==0){
if(!valid_map(Value)) {
selfmessage("Map existiert nicht!");
return PLUGIN_HANDLED;
}
}
else if(strcasecmp(CVar,"admin_war_rules")==0){
new rule[MAX_DATA_LENGTH];
snprintf(rule,MAX_DATA_LENGTH,"%s%s",ruledir,Value);
if(!fileexists(rule)) {
selfmessage("Regeldatei existiert nicht!");
return PLUGIN_HANDLED;
}
new on;
get_vaultnumdata("admin_war_on",on);
if(on){
new execrule[MAX_TEXT_LENGTH];
snprintf(execrule,MAX_DATA_LENGTH,"exec %s%s",ruledir,Value);
writefile(warcfg,execrule,2);
exec(execrule);
set_timer("warmup_init",5,0);
say("Map-Settings werden in 5 Sekunden neu gesetzt!");
}
}
else if(strcasecmp(CVar,"admin_war_count")==0 || strcasecmp(CVar,"admin_war_demo")==0){
iNum=strtonum(Value);
if(iNum<0 || iNum>1) {
selfmessage("Ungueltiger Wert! Waehle 1 oder 0.");
return PLUGIN_HANDLED;
}
}
else if(strcasecmp(CVar,"admin_war_countrules")==0){
if(strcasecmp(Value,"attack")!=0 && strcasecmp(Value,"all")!=0) {
selfmessage("Ungueltiger Wert! Waehle attack oder all.!");
return PLUGIN_HANDLED;
}
}
}
setorinfo(CVar,Value);
return PLUGIN_HANDLED;
}
/************* INIT ********************/
public plugin_init() {
new write=getvar("file_access_write");
new read=getvar("file_access_read");
new vault[MAX_DATA_LENGTH];
new ivault=1;
new execute=getvar("allow_client_exec");
getstrvar("admin_vault_file",vault,MAX_DATA_LENGTH);
if(streq(vault,"0")){
ivault=0;
}
if(write==1 && read==1 && ivault==1 && execute){
plugin_registerinfo("Clan War Creator","Sets server settings for CWs.",STRING_VERSION);
plugin_registercmd("admin_war_set","admin_war_set",ACCESS_WAR,"admin_war_set <OpponentClanTag>");
plugin_registercmd("admin_war_start","admin_war_start",ACCESS_WAR,"admin_war_start");
plugin_registercmd("admin_war_restart","admin_war_restart",ACCESS_WAR,"admin_war_restart");
plugin_registercmd("admin_war_end","admin_war_end",ACCESS_WAR,"admin_war_end");
plugin_registercmd("admin_war_tag","admin_war_cvar",ACCESS_WAR,"admin_war_tag <eigener Clan-Tag>");
plugin_registercmd("admin_war_pass","admin_war_cvar",ACCESS_WAR,"admin_war_pass <CW Passwort>");
plugin_registercmd("admin_war_map1","admin_war_cvar",ACCESS_WAR,"admin_war_map1 <1.CW-Map>");
plugin_registercmd("admin_war_map2","admin_war_cvar",ACCESS_WAR,"admin_war_map2 <2.CW-Map>");
plugin_registercmd("admin_war_endmap","admin_war_cvar",ACCESS_WAR,"admin_war_endmap <Map nach Ende des Wars>");
plugin_registercmd("admin_war_rules","admin_war_cvar",ACCESS_WAR,"admin_war_rules <Regeldatei>");
plugin_registercmd("admin_war_count","admin_war_cvar",ACCESS_WAR,"admin_war_count <0/1>");
plugin_registercmd("admin_war_demo","admin_war_cvar",ACCESS_WAR,"admin_war_demo <0/1>");
plugin_registercmd("admin_war_countrules","admin_war_cvar",ACCESS_WAR,"admin_war_countrules <attack/all>");
plugin_registercmd("admin_war_sc","admin_war_cvar",ACCESS_WAR,"admin_war_sc <0/1>");
/******* Einstellungen besorgen *******/
new i;
if(fileexists(settings)){
for(i=1;i<=11;i++){
readfile(settings,cvar[i-1],i,MAX_DATA_LENGTH);
}
}
else{
for(i=1;i<=14;i++){
writefile(settings,cvar[i-1],-1);
}
}
/******* Im Warmodus? Passwort setzen und Mapsettings ueberschreiben ****/
new Text[MAX_TEXT_LENGTH]="sv_password ";
new on;
get_vaultnumdata("admin_war_on",on);
if(on==1) {
exec("say War-Password ist gesetzt!");
strcat(Text,cvar[0],MAX_TEXT_LENGTH);
exec(Text);
set_timer("nomapsets",10,0);
get_vaultnumdata("admin_war_rs",on);
readfile(settings,cvar[11],12,MAX_DATA_LENGTH);
round=strtonum(cvar[11]);
if(on){
round++;
numtostr(round,cvar[11]);
writefile(settings,cvar[11],11);
}
set_vaultnumdata("admin_war_rs",0);
}
}
else{
plugin_registerinfo("Clan War Creator","Disabled! Check your cvars",STRING_VERSION);
log("Check file_access_read, file_access_write, admin_vault_file.");
}
return PLUGIN_CONTINUE;
}