ob es vorher die probs gab kann ich nicht sagen, weil ich da nur kurz angerissen habe. (nicht über einen mapwechsel hinaus)
Code:
/*Spectator Block by [AsC]Phil
* Converted for Admin Mod by [WING] Black Knight
*
*Small plugin to only allow the admins to use spectator mode.
*Other players are not allowed to use it.
*
*Admins need ban abilility to be allowed.
*Use admin_nospec to enable or disable spec mode watching for normal players (0 = no spec mode enabled)
*
*/
#include <core>
#include <console>
#include <string>
#include <admin>
#include <adminlib>
#include <plugin>
#define DEBUG 0
#define MAX_TEAMS 2
new STRING_VERSION[MAX_DATA_LENGTH] = "1.0";
new g_User[MAX_PLAYERS];
new g_UserSpecMode[MAX_PLAYERS];
new g_iNoSpec;
new g_WaitTeamSelect=60; /*60 Sekunden die nach dem Connect des Spielers gewartet werden. Dann wird automatisch eine Teamauswahl durhgeführt*/
public specmode(HLCommand,HLData,HLUserName,UserIndex) {
/*Nur einmal specmode kontrollieren nach dem ersten Connect/Enter!*/
if(g_UserSpecMode[UserIndex]==0 && g_iNoSpec==1 && !access(ACCESS_BAN)|| !getvar("allow_spectators")){
g_UserSpecMode[UserIndex]=1;
g_User[UserIndex]=1;
new sUserIndex[3];
numtostr(UserIndex,sUserIndex);
set_timer("auto_assign_player",g_WaitTeamSelect,0,sUserIndex);
}
return PLUGIN_CONTINUE;
}
public auto_assign_player(Timer,Repeat,HLName,HLParam) {
new Player[MAX_NAME_LENGTH];
new sUserIndex[3];
new UserIndex;
convert_string(HLParam,sUserIndex,3);
UserIndex=strtonum(sUserIndex);
if(g_User[UserIndex]==1){
if(playerinfo(UserIndex,Player,MAX_NAME_LENGTH)){
messageex(Player,"Iddlen nicht erlaubt !!",print_console);
kick(Player);
}
}
}
public chooseteam(HLCommand,HLData,HLUserName,UserIndex) {
g_User[UserIndex]=1;
return PLUGIN_CONTINUE;
}
public menuselect(HLCommand,HLData,HLUserName,UserIndex) {
new Data[MAX_DATA_LENGTH];
new sName[MAX_NAME_LENGTH];
new iTeam;
new iData;
if(g_User[UserIndex]){
convert_string(HLData,Data,MAX_DATA_LENGTH);
iData=strtonum(Data);
if(iData==1 || iData==2 || iData==5 || iData==10){
g_User[UserIndex]=0;
}
if(iData==6){
if(!access(ACCESS_BAN) && g_iNoSpec == 1 || !getvar("allow_spectators") ){
g_User[UserIndex]=0;
convert_string(HLUserName,sName,MAX_NAME_LENGTH);
messageex(sName,"Spectator mode is currently forbidden!",print_chat);
get_userTeam(sName,iTeam);
execclient(sName,"chooseteam");
if(iTeam>MAX_TEAMS){
execclient(sName,"menuselect 5");
execclient(sName,"menuselect 1");
}
return PLUGIN_HANDLED;
}
}
}
return PLUGIN_CONTINUE;
}
public admin_nospec(HLCommand,HLData,HLUserName,UserIndex) {
new sData[MAX_DATA_LENGTH];
convert_string(HLData,sData,MAX_NAME_LENGTH);
if(sData[0]=='1'){
set_vaultnumdata("NOSPEC",1);
g_iNoSpec=1;
selfmessage("SPECTATOR MODE ONLY FOR ADMINS WITH ACCESS_BAN ENABLED!");
} else{
set_vaultnumdata("NOSPEC",0);
g_iNoSpec=0;
selfmessage("SPECTATOR MODE FOR EVERY PLAYER AVAILABLE!");
}
return PLUGIN_HANDLED;
}
#if DEBUG == 1
public plugin_command(HLCommand,HLData,HLUserName,UserIndex) {
new sText[MAX_TEXT_LENGTH];
new sCommand[MAX_COMMAND_LENGTH];
new sData[MAX_DATA_LENGTH];
new sName[MAX_NAME_LENGTH];
convert_string(HLCommand,sCommand,MAX_COMMAND_LENGTH);
convert_string(HLData,sData,MAX_DATA_LENGTH);
convert_string(HLUserName,sName,MAX_NAME_LENGTH);
snprintf(sText,MAX_TEXT_LENGTH,"[CHECK-COMMANDS] %s used %s with %s",sName,sCommand,sData);
say(sText);
return PLUGIN_CONTINUE;
}
#endif
public SetMenuData(HLCommand,HLData,HLUserName,UserIndex) {
g_User[UserIndex]=0;
return PLUGIN_CONTINUE;
}
public plugin_init() {
plugin_registerinfo("Spectator Block","Blocks non-admins from spectating.",STRING_VERSION);
plugin_registercmd("admin_nospec","admin_nospec",ACCESS_BAN,"admin_nospec: 1 enables nospec mode, 2 disables it.");
plugin_registercmd("specmode","specmode",ACCESS_ALL);
plugin_registercmd("chooseteam","chooseteam",ACCESS_ALL);
plugin_registercmd("menuselect","menuselect",ACCESS_ALL);
plugin_registercmd("radio1","SetMenuData",ACCESS_ALL);
plugin_registercmd("radio2","SetMenuData",ACCESS_ALL);
plugin_registercmd("radio3","SetMenuData",ACCESS_ALL);
plugin_registercmd("buyequip","SetMenuData",ACCESS_ALL);
plugin_registercmd("buy","SetMenuData",ACCESS_ALL);
plugin_registercmd("chooseteam","SetMenuData",ACCESS_ALL);
plugin_registercmd("showbriefing","SetMenuData",ACCESS_ALL);
/*Automatisch NOSPEC 1 setzen, wenn vault.ini Eintrag nicht existiert!*/
if(!get_vaultnumdata("NOSPEC",g_iNoSpec)){
set_vaultnumdata("NOSPEC",1);
g_iNoSpec=1;
}
return PLUGIN_CONTINUE;
}