Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // License:
- /*
- Timeleft And Nextmap Bots v1.0
- Copyright (C) 2013 Hyuna aka NorToN
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- #include <amxmodx>
- #include <amxmisc>
- #include <cstrike>
- #include <fakemeta>
- new g_nextmapbot,g_timeleftbot,g_timebot;
- new g_nextmapcvar,g_timelimitcvar;
- const Float:g_UpdateTime = 1.0;
- public plugin_init(){
- register_plugin("Timeleft and Nextmap bots","1.0","Hyuna");
- register_forward(FM_ClientUserInfoChanged,"ClientUserInfoChanged");
- register_dictionary("nextmap.txt");
- register_dictionary("timeleft.txt");
- set_task(5.0,"CreateBots");
- g_nextmapcvar = get_cvar_pointer("amx_nextmap");
- g_timelimitcvar = get_cvar_pointer("mp_timelimit");
- }
- public CreateBots(){
- g_nextmapbot = CreateBot();
- g_timeleftbot = CreateBot();
- g_timebot = CreateBot();
- updatebotname();
- updatebotname2();
- updatebotname3();
- }
- public ClientUserInfoChanged(id){
- static szOldName[32];
- pev(id,pev_netname,szOldName,charsmax(szOldName));
- if(szOldName[0] && (id == g_nextmapbot || id == g_timeleftbot || id == g_timebot))
- {
- static szNewName[32];
- get_user_info(id,"name",szNewName,charsmax(szNewName));
- if(!equal(szOldName,szNewName))
- {
- set_pev(id,pev_netname,szNewName);
- return FMRES_HANDLED;
- }
- }
- return FMRES_IGNORED;
- }
- public updatebotname(){
- if (!is_user_connected(g_nextmapbot))
- return;
- static some[64],some2[128];
- get_pcvar_string(g_nextmapcvar,some,63);
- formatex(some2,128,"%L %s",LANG_SERVER,"NEXT_MAP",some);
- set_user_info(g_nextmapbot,"name",some2);
- set_task(g_UpdateTime,"updatebotname");
- }
- public updatebotname2(){
- if (!is_user_connected(g_timeleftbot))
- return;
- static some[64];
- static iHours,iMinutes,iSeconds;
- if(get_pcvar_float(g_timelimitcvar))
- {
- iSeconds = get_timeleft();
- iMinutes = iSeconds / 60;
- iHours = iMinutes / 60;
- iSeconds = iSeconds - iMinutes * 60;
- iMinutes = iMinutes - iHours * 60;
- if (iHours)
- formatex(some,63,"%L: %d:%02d:%02d",LANG_SERVER,"TIME_LEFT",iHours,iMinutes,iSeconds);
- else
- formatex(some,63,"%L: %d:%02d",LANG_SERVER,"TIME_LEFT",iMinutes,iSeconds);
- }
- else
- formatex(some,63,"%L: %L",LANG_SERVER,"TIME_LEFT",LANG_SERVER,"NO_T_LIMIT");
- set_user_info(g_timeleftbot,"name",some);
- set_task(g_UpdateTime,"updatebotname2");
- }
- public updatebotname3(){
- static times[24],some[32];
- get_time("%d/%m/%Y - %H:%M:%S",times,23);
- formatex(some,31,"%L: %s",LANG_SERVER,"THE_TIME",times);
- set_user_info(g_timebot,"name",some);
- set_task(g_UpdateTime,"updatebotname3");
- }
- stock CreateBot(){
- new some[32];
- formatex(some,31,"BOT-%d",random(1337));
- new Bot = engfunc(EngFunc_CreateFakeClient,some);
- if (Bot > 0) {
- //Supposed to prevent crashes?
- dllfunc(MetaFunc_CallGameEntity,"player",Bot);
- set_pev(Bot,pev_flags,FL_FAKECLIENT);
- //Make Sure they have no model
- set_pev(Bot,pev_model,"");
- set_pev(Bot,pev_viewmodel2,"");
- set_pev(Bot,pev_modelindex,0);
- //Make them invisible for good measure
- set_pev(Bot,pev_renderfx,kRenderFxNone);
- set_pev(Bot,pev_rendermode,kRenderTransAlpha);
- set_pev(Bot,pev_renderamt,0.0);
- //Set the team if we need to for this mod
- if (cstrike_running())
- cs_set_user_team(Bot,CS_TEAM_UNASSIGNED);
- log_amx("Bot ^"%s^" (ID: %d) was successfuly created!",some,Bot);
- }
- else
- set_fail_status("ERROR: Falied to create a bot (Invaild bot entity index %d)",Bot);
- return Bot;
- }
- stock set_fail_status(err_msg[], any: ...){
- new msg[512];
- vformat(msg,charsmax(msg),err_msg,2);
- set_fail_state(msg)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement