-
-
Save conradfr/a20e9c9598b7b65ad94b8a8605fa1c42 to your computer and use it in GitHub Desktop.
Small/Pawn script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* plugin_match by Conrad for AdminMod | |
* v0.1 / 02/10/01 | |
* | |
*/ | |
/* This is a base plugin for Admin Mod; it doesn't do anything fancy. */ | |
#include <core> | |
#include <console> | |
#include <string> | |
#include <admin> | |
#include <adminlib> | |
/* team status */ | |
#define TEAM_UNREADY 0 | |
#define TEAM_READY 1 | |
#define TEAM_KNIFE 2 | |
/* match status */ | |
#define MATCH_NOTSTARTED 0 | |
#define MATCH_ROUND1_ABOUT2START 10 | |
#define MATCH_ROUND1_ABOUT2START2 101 | |
#define MATCH_ROUND1_STARTED 11 | |
#define MATCH_ROUND1_ENDED 12 | |
#define MATCH_ROUND2_ABOUT2START 20 | |
#define MATCH_ROUND2_ABOUT2START2 201 | |
#define MATCH_ROUND2_STARTED 21 | |
#define MATCH_ROUND2_ENDED 22 | |
#define MATCH_ENDED 30 | |
#define NAME 0 | |
#define AUTH 1 | |
#define STATUS 2 | |
#define SCORE 3 | |
new STRING_VERSION[MAX_DATA_LENGTH] = "0.1"; | |
new MatchStatus = MATCH_NOTSTARTED; | |
/* TEAMS "class" */ | |
new Team1_name[MAX_NAME_LENGTH] = ""; | |
new bool:Team1_auth = false; | |
new Team1_Status = 0; | |
new Team1_Score = 0; | |
new Team1_Login[MAX_NAME_LENGTH] = ""; | |
new Team2_name[MAX_NAME_LENGTH] = ""; | |
new bool:Team2_auth = false; | |
new Team2_Status = 0; | |
new Team2_Score = 0; | |
new Team2_Login[MAX_NAME_LENGTH] = ""; | |
/* misc */ | |
new TmpStr[MAX_NAME_LENGTH] = ""; | |
new Value2; | |
new z = 0; | |
/* timer */ | |
new RoundTime = 2; | |
new RoundTimeStart; | |
/* ----------------------------------------------------------------------------------------------- | |
PRIVATE API | |
----------------------------------------------------------------------------------------------- */ | |
public countdown_timeleft() { | |
/* n1 */ | |
} | |
/* 1st restart done */ | |
public countdown_1start() { | |
new sRconCmd[MAX_DATA_LENGTH]; | |
if (MatchStatus == MATCH_ROUND1_ABOUT2START) { | |
MatchStatus = MATCH_ROUND1_ABOUT2START2; | |
snprintf(sRconCmd, MAX_DATA_LENGTH, "%s %s", "sv_restartround", "3"); | |
exec(sRconCmd); | |
snprintf(sRconCmd, MAX_DATA_LENGTH, "%s %s", "say", "2nd restart"); | |
exec(sRconCmd); | |
} | |
else | |
if (MatchStatus == MATCH_ROUND2_ABOUT2START) { | |
MatchStatus = MATCH_ROUND2_ABOUT2START2; | |
snprintf(sRconCmd, MAX_DATA_LENGTH, "%s %s", "sv_restartround", "3"); | |
exec(sRconCmd); | |
snprintf(sRconCmd, MAX_DATA_LENGTH, "%s %s", "say", "2nd restart"); | |
exec(sRconCmd); | |
} | |
return PLUGIN_CONTINUE; | |
} | |
/* 2nd restart done */ | |
public countdown_2start() { | |
new sRconCmd[MAX_DATA_LENGTH]; | |
if (MatchStatus == MATCH_ROUND1_ABOUT2START2) { | |
MatchStatus = MATCH_ROUND1_STARTED; | |
RoundTimeStart = systemtime(); | |
snprintf(TmpStr,MAX_TEXT_LENGTH, "!! MATCH HAS STARTED !!"); | |
centersay(TmpStr,15,250,10,10); | |
snprintf(sRconCmd, MAX_DATA_LENGTH, "%s %s", "say", TmpStr); | |
exec(sRconCmd); | |
} | |
else | |
if (MatchStatus == MATCH_ROUND2_ABOUT2START2) { | |
MatchStatus = MATCH_ROUND2_STARTED; | |
RoundTimeStart = systemtime(); | |
snprintf(TmpStr,MAX_TEXT_LENGTH, "!! ROUND 2 HAS STARTED !!"); | |
centersay(TmpStr,15,250,10,10); | |
snprintf(sRconCmd, MAX_DATA_LENGTH, "%s %s", "say", TmpStr); | |
exec(sRconCmd); | |
} | |
return PLUGIN_HANDLED; | |
} | |
/* end of round */ | |
public endround() { | |
new sRconCmd[MAX_DATA_LENGTH]; | |
if (MatchStatus == MATCH_ROUND1_STARTED) { | |
MatchStatus = MATCH_ROUND1_ENDED; | |
snprintf(TmpStr,MAX_TEXT_LENGTH, "!! End of the FIRST round !!^nPlease switchs teams."); | |
centersay(TmpStr,15,250,10,10) | |
snprintf(sRconCmd, MAX_DATA_LENGTH, "%s %s", "say", TmpStr); | |
exec(sRconCmd); | |
/* reset team status */ | |
Team1_Status = TEAM_UNREADY; | |
Team2_Status = TEAM_UNREADY; | |
switchteams(); | |
} | |
else | |
if (MatchStatus == MATCH_ROUND2_STARTED) { | |
MatchStatus = MATCH_ENDED; | |
snprintf(TmpStr,MAX_TEXT_LENGTH, "!! MATCH ENDED !!^n^nSCORE OF TEAM 1 (%s) : %d^nSCORE OF TEAM 2 (%s) : %d",Team1_name,Team1_Score,Team2_name,Team2_Score); | |
centersay(TmpStr,15,250,10,10) | |
snprintf(sRconCmd, MAX_DATA_LENGTH, "%s %s", "say", TmpStr); | |
exec(sRconCmd); | |
} | |
return PLUGIN_HANDLED; | |
} | |
public switchteams() | |
{ | |
/* | |
new i; | |
new maxplayers = maxplayercount(); | |
new SessionID; | |
new Target[MAX_NAME_LENGTH]; | |
new Team; | |
new WONID; | |
new Text[MAX_DATA_LENGTH]; | |
snprintf(Text, MAX_DATA_LENGTH, "Your team has been switched."); | |
say(Text); | |
centersay("Your team has just been switched.",10,255,0,0); | |
for(i=1; i<=maxplayers; i++) { | |
strinit(Target); | |
if(playerinfo(i,Target,MAX_NAME_LENGTH,SessionID,WONID,Team)==1) { | |
if(Team==1) { | |
snprintf(Text, MAX_DATA_LENGTH, "gnnnniiii 1"); | |
say(Text); | |
execclient(Target,"say super; wait; chooseteam; wait; menuselect 2; wait; menuoff"); | |
} | |
if(Team==2) { | |
snprintf(Text, MAX_DATA_LENGTH, "gnnnniiii 2"); | |
say(Text); | |
execclient(Target,"say cool; wait; chooseteam; wait; menuselect 1; wait; menuoff"); | |
} | |
} | |
} | |
*/ | |
/* log_command(User,Command,Data); */ | |
return PLUGIN_HANDLED; | |
} | |
/* ----------------------------------------------------------------------- */ | |
public GetPlayerTeam(HLUserName) { | |
new i = 0; | |
new PropName[MAX_TEXT_LENGTH]; | |
new User[MAX_NAME_LENGTH] = ""; | |
convert_string(HLUserName,User,MAX_NAME_LENGTH); | |
for(i=1; i<=2; i++) { | |
snprintf(PropName,MAX_TEXT_LENGTH, "Team%d_Login" , i); | |
if(strcasecmp(User,PropName) == 0 ) { return i;} | |
else { return 0; } | |
} | |
return 0; | |
} | |
/* | |
*********************** | |
* * | |
* MATCH BEGIN * | |
* * | |
*********************** | |
*/ | |
public BeginMatch(HLUserName) { | |
new User[MAX_NAME_LENGTH]; | |
convert_string(HLUserName,User,MAX_NAME_LENGTH); | |
new sRconCmd[MAX_DATA_LENGTH]; | |
if (MatchStatus == MATCH_NOTSTARTED) { | |
snprintf(sRconCmd, MAX_DATA_LENGTH, "%s %s", "mp_timelimit", "32"); | |
exec(sRconCmd); | |
snprintf(sRconCmd, MAX_DATA_LENGTH, "%s %s", "mp_c4timer", "35"); | |
exec(sRconCmd); | |
snprintf(sRconCmd, MAX_DATA_LENGTH, "%s %s", "mp_roundtime", "4"); | |
exec(sRconCmd); | |
snprintf(sRconCmd, MAX_DATA_LENGTH, "%s %s", "mp_winlimit", "0"); | |
exec(sRconCmd); | |
MatchStatus = MATCH_ROUND1_ABOUT2START; | |
} | |
else { | |
MatchStatus = MATCH_ROUND2_ABOUT2START; | |
} | |
/* Restart Round 2 times */ | |
snprintf(sRconCmd, MAX_DATA_LENGTH, "%s %s", "sv_restartround", "10"); | |
exec(sRconCmd); | |
snprintf(sRconCmd, MAX_DATA_LENGTH, "%s %s", "say", "1st restart"); | |
exec(sRconCmd); | |
/* timers */ | |
set_timer("countdown_1start", 10,1); | |
set_timer("countdown_2start", 14,1); | |
set_timer("endround", RoundTime * 60 + 14 ,1); | |
} | |
/* ----------------------------------------------------------------------------------------------- | |
PUBLIC API | |
----------------------------------------------------------------------------------------------- */ | |
/* timeleft */ | |
/* display timeleft for 1 people (if call by player) or all (if call by script) */ | |
public timeleft2(HLCommand,HLData,HLUserName,UserIndex) { | |
new User[MAX_NAME_LENGTH]; | |
convert_string(HLUserName,User,MAX_NAME_LENGTH); | |
new Msg[MAX_DATA_LENGTH]; | |
new Elapsed; | |
new ElapsedM; | |
new ElapsedS; | |
Elapsed = systemtime(); | |
Elapsed = (Elapsed - RoundTimeStart); | |
ElapsedM = (Elapsed / 60); | |
ElapsedS = (Elapsed - (ElapsedM * 60) ); | |
snprintf(Msg, MAX_DATA_LENGTH, "Timeleft : %i:%i", ElapsedM,ElapsedS); | |
/* display */ | |
if (streq(User,"")) { | |
snprintf(Msg, MAX_DATA_LENGTH, "%s%s", "say ",Msg); | |
exec(Msg); | |
} | |
else { | |
messageex(User,Msg, print_center); | |
} | |
return PLUGIN_HANDLED; | |
} | |
/* AUTH PROCEDURE */ | |
public match_auth(HLCommand,HLData,HLUserName,UserIndex) { | |
new Command[MAX_COMMAND_LENGTH]; | |
new Data[MAX_DATA_LENGTH]; | |
new User[MAX_NAME_LENGTH]; | |
new TeamName[MAX_NAME_LENGTH]; | |
new Passw[MAX_NAME_LENGTH]; | |
new Msg[MAX_NAME_LENGTH]; | |
new i; | |
convert_string(HLCommand,Command,MAX_COMMAND_LENGTH); | |
convert_string(HLData,Data,MAX_DATA_LENGTH); | |
convert_string(HLUserName,User,MAX_NAME_LENGTH); | |
/* parse params */ | |
strbreak(Data,TeamName,Passw,MAX_DATA_LENGTH); | |
/* verify auth */ | |
if (streq(Passw,"coucou")==1) { | |
/* if team1 is already set set to team2 */ | |
if (streq(Team1_name,"")/* && streq(Team1_name,TeamName ) != 0*/) { | |
strcpy(Team1_name, TeamName,MAX_TEXT_LENGTH); | |
Team1_auth = true; | |
strcpy(Team1_Login,User,MAX_NAME_LENGTH); | |
i = 1; | |
} | |
else { | |
strcpy(Team2_name, TeamName,MAX_TEXT_LENGTH); | |
Team2_auth = true; | |
strcpy(Team2_Login,User,MAX_NAME_LENGTH); | |
i = 2; | |
} | |
/* meg 2 user */ | |
snprintf(Msg, MAX_TEXT_LENGTH, "Hi %s ! You have been authentified for the team %d : %s",User,i,TeamName); | |
selfmessage(Msg); | |
} | |
else { | |
/* Msg = "Password error ! You has NOT been authentificated !"; */ | |
snprintf(Msg, MAX_TEXT_LENGTH, "AUTH ERROR : %s of %s ou haven't been auth !",User,TeamName); | |
selfmessage(Msg); | |
} | |
return PLUGIN_HANDLED; | |
} | |
/* SET TEAM READY PROCEDURE */ | |
public match_ready(HLCommand,HLData,HLUserName,UserIndex) { | |
new User[MAX_NAME_LENGTH]; | |
convert_string(HLUserName,User,MAX_NAME_LENGTH); | |
/* | |
snprintf(TmpStr,MAX_TEXT_LENGTH, "HHH : %i",systemtime()); | |
say(TmpStr); | |
*/ | |
if (streq(Team1_Login, User) == 1) { | |
Team1_Status = TEAM_READY; | |
selfmessage("Your team has been set to 'READY'"); | |
/* 1 or 2 teams ready ? */ | |
if (Team2_Status == TEAM_READY) { | |
snprintf(TmpStr,MAX_TEXT_LENGTH, "Team 1 (%s) is ready. Match/round won't start until Team 2 (%s) is ready.",Team1_name, Team2_name); | |
centersay(TmpStr,20,250,10,10); | |
} | |
else { | |
snprintf(TmpStr,MAX_TEXT_LENGTH, "Both teams are ready, match/round is about to start",Team1_name, Team2_name); | |
centersay(TmpStr,10,250,10,10); | |
BeginMatch(HLUserName); | |
} | |
} | |
else { | |
if (streq(Team2_Login, User) == 1) { | |
Team2_Status = TEAM_READY; | |
selfmessage("Your team has been set to 'READY'"); | |
/* 1 or 2 teams ready ? */ | |
if (Team1_Status != TEAM_READY) { | |
snprintf(TmpStr,MAX_TEXT_LENGTH, "Team 2 (%s) is ready. Match/Round won't start until Team 1 (%s) is ready.",Team2_name, Team1_name); | |
centersay(TmpStr,20,250,10,10); | |
} | |
else { | |
snprintf(TmpStr,MAX_TEXT_LENGTH, "Both teams are ready, match/round is about to start",Team1_name, Team2_name); | |
centersay(TmpStr,10,250,10,10); | |
BeginMatch(HLUserName); | |
} | |
} | |
} | |
return PLUGIN_HANDLED; | |
} | |
public about(User) { | |
/* new User[MAX_NAME_LENGTH];/ | |
convert_string(HLName,User,MAX_NAME_LENGTH); */ | |
/* messageex(User,"This server is using the plugin_match by Conrad^nhttp://conradworld.free.fr/pluginmatch/", print_center ); */ | |
/* centersay("This server is using the plugin_match by Conrad^nhttp://conradworld.free.fr/pluginmatch/",10,10,250,10); */ | |
} | |
/* ----------------------------------------------------------------------- */ | |
public plugin_connect(HLName,HLIP,UserIndex) { | |
/* new User[MAX_NAME_LENGTH]; | |
convert_string(HLName,User,MAX_NAME_LENGTH) */ | |
/* set_timer("about",10,1); */ | |
return PLUGIN_CONTINUE; | |
} | |
public plugin_init() { | |
plugin_registerinfo("plugin_match","Match manager for CS",STRING_VERSION); | |
plugin_registercmd("match_auth","match_auth",ACCESS_ALL,"auth procedure"); | |
plugin_registercmd("match_ready","match_ready",ACCESS_ALL,"declare a team ready"); | |
plugin_registercmd("timeleft2","timeleft2",ACCESS_ALL,"timeleft"); | |
return PLUGIN_CONTINUE; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment