AdminMod.de
https://www.adminmod.de/

Spawn-Wallshot Plugin - Problem
https://www.adminmod.de/viewtopic.php?t=9808
Seite 1 von 1

Autor:  Belzebub [ 23.04.2006, 22:34 ]
Betreff des Beitrags:  Spawn-Wallshot Plugin - Problem

Hi Leute!
Ich hab das FT Spawn-Kill Plugin mal ein bisschen umgecoded und da ein Anti Spawn-Wallshot Plugin rausgemacht.
Der Sinn des Ganzen soll sein, dass auf Iceworld doch einige Leute desöfteren direkt losballern und auf der anderen Seite die Leute dann teilweise mit nur 50HP oder noch weniger loslaufen dürfen.

Features sind:
Innerhalb der ersten 7 Sekunden nach Rundenstart (einstellbar) und innerhalb einer bestimmten Zone (also ein kleiner Bereich in den man spawned; Grösse der Zone ist auch einstellbar) darf kein gegnerischer Spieler angeschossen werden. Falls doch kann bei Bedarf geslapped, geslayed oder gekickt werden, je nachdem was eingestellt ist. Das ganze Plugin wird nach den oben eingestellten 7 Sekunden nach Rundenstart deaktiviert, falls man innerhalb der Runde doch zufällig wieder in der Spawn-Zone steht und jemanden trifft, das man dann nicht bestraft wird.

Das Plugin hat aber noch ein Bug den ich einfach nich rauskriege...

Jedesmal bei Rundenstart gibt er mir als Koordinaten für den Spawn-Punkt 0 - 0 - 0 an ...

Die Frage ist also, wie kriege ich das Plugin dazu, dass es für jeden einzelnen Spieler die Start-Koordinaten separat speichert und falls ein Spieler einen Gegner durch die Wand bei Spawn-Attack trifft, diese Koordinaten abruft und mit den aktuellen Koordinaten vergleicht ?

Hier ist das Plugin:
Code:
#include <core>
#include <console>
#include <string>
#include <plugin>
#include <admin>
#include <adminlib>

/* ******************************************************
    Alter these defines if necessary to suit your needs.
   ******************************************************/

#define SPAWN_TIME 7          		  /* CRITICAL: How long after the freeze time is over will damages be
                                               considered 'spawn damage' */
#define DEFAULT_SD_TYPE 1                   /* How should we punish spawn damagers? 0=admin_slap 1=admin_slay 2=admin_kick 3=HL kick 
                                               This can also be configured via the ft_sd_type cvar in-game. */
#define MAX_SPAWN_TIME 60                   /* Don't let the spawn time to be set over this limit */
#define ANNOUNCE_TIME 0                     /* Should the spawn time var be announced after a slay? (0|1)*/

#define DISPLAY_TIME 7                      /* How long should the slay/announce messages stay up? */
#define DISPLAY_RED 208                     /* TSay message colors (RGB) */
#define DISPLAY_GREEN 20
#define DISPLAY_BLUE 20

#define ACCESS_RCON 65536
#define ACCESS_CONSOLE 131072


/* ***********************************************************
       You do not need to modify anything below this line.
   ***********************************************************/

#define ACCESS_CONSOLE 131072               /* You can ignore this access level */

// Global vars
new STRING_VERSION[] = "1.01";

new g_Spawn_Time=SPAWN_TIME;                /* Main var for how long spawn damaging is in effect*/
new g_Type=DEFAULT_SD_TYPE;                 /* Main var for which type of punishment we will use*/
new g_Announce_Time=ANNOUNCE_TIME;          /* Var for announcing how long spawn damaging is set at*/

new g_SDStart = 0;

new g_area;
new g_User_X[MAX_PLAYERS];
new g_User_Y[MAX_PLAYERS];
new g_User_Z[MAX_PLAYERS];

/* Function declarations */
forward FT_SD_Punish(UserName[MAX_NAME_LENGTH]);
forward FTLogdDamage(HLCommand,HLData,HLUserName,UserIndex);
forward FTLogdWorldAction(HLCommand,HLData,HLUserName,UserIndex);
forward ft_sd_spawn_time(HLCommand,HLData,HLUserName,UserIndex);
forward ft_sd_announce_time(HLCommand,HLData,HLUserName,UserIndex);
forward ft_sd_type(HLCommand,HLData,HLUserName,UserIndex);
forward ft_sd_area(HLCommand,HLData,HLUserName,UserIndex);

// Function that actually punishes the player
// 1=admin_slay / 2=admin_kick / 3=kick

public FT_SD_Punish(UserName[MAX_NAME_LENGTH])
{
  new revert_cmd=0;
  new command[MAX_TEXT_LENGTH];

  if (g_Type==0)
  {
    if (plugin_checkcommand("admin_slap")>0)
      plugin_exec("admin_slap",UserName);
    else
      revert_cmd = 1;
  }
  else if (g_Type==1)
  {
    if (plugin_checkcommand("admin_slay")>0)
      plugin_exec("admin_slay",UserName);
    else
      revert_cmd = 1;
  }
  else if (g_Type==2)
  {
    if (plugin_checkcommand("admin_kick")>0) {
      plugin_exec("admin_kick",UserName);
    } else {
      revert_cmd = 1;
    }
  }
  else if (g_Type==3)
  {
    snprintf(command, MAX_TEXT_LENGTH, "kick '%s'", UserName);
    exec(command);
  }
  else
  {
    if (plugin_checkcommand("admin_slay")>0) {
//      plugin_exec("admin_slay",UserName);
	slay(UserName);
    } else {
      revert_cmd = 1;
    }
  }

  // If we couldn't run the admin_ command, revert to the original HL kick command
  if (revert_cmd == 1)
  {
    snprintf(command, MAX_TEXT_LENGTH, "kick '%s'", UserName);
    exec(command);
  }

}

reset(UserIndex){
	new i;
	new maxplayers=maxplayercount();
	if(!UserIndex){
		for(i=1;i<=maxplayers;i++){
			g_User_X[i]=0;
			g_User_Y[i]=0;
			g_User_Z[i]=0;
		}
	}else{
		g_User_X[UserIndex]=0;
		g_User_Y[UserIndex]=0;
		g_User_Z[UserIndex]=0;
	}
}


/*********************************************************
 *                 LOGD CALLBACK HANDLERS                *
 *********************************************************
 Totally rewritten by Belzebub 04/2006
*/

public FTLogdDamage(HLCommand,HLData,HLUserName,UserIndex)
{
    new Data[MAX_DATA_LENGTH];
   
    // This is the Main Check !
    if( g_SDStart + g_Spawn_Time <= systemtime() ){
	return PLUGIN_CONTINUE;
	}

    // Parse the values
    new Text[MAX_TEXT_LENGTH] = "";
    new iWinner;
    new idWinner[MAX_DATA_LENGTH];
    new idLoser[MAX_DATA_LENGTH];
    new AuthIDi[MAX_AUTHID_LENGTH];

    convert_string(HLData,Data,MAX_DATA_LENGTH);
    strsplit(Data, " ",idWinner,MAX_DATA_LENGTH, idLoser, MAX_DATA_LENGTH);

    iWinner = strtonum(idWinner);

    new name[MAX_NAME_LENGTH];

    // Make sure this is a real player??
    if (!playerinfo(iWinner, name, MAX_NAME_LENGTH)) {
        return PLUGIN_CONTINUE;
    }
    
    new i;
    new maxplayers=maxplayercount();
    new X;
    new Y;
    new Z;
    new iTeam;
    new iDead;

    for(i=1;i<=maxplayers;i++){
	    if(playerinfo(iWinner,name,MAX_NAME_LENGTH,_,_,iTeam,iDead)){
		    if(!iDead && iTeam <= 2){
			get_userorigin(name,X,Y,Z);
			snprintf(Data,MAX_DATA_LENGTH,"Vorher: %i - %i - %i",g_User_X[i],g_User_Y[i],g_User_Z[i]);
			say(Data);
			snprintf(Data,MAX_DATA_LENGTH,"Derzeit: %i - %i - %i",X,Y,Z);
			say(Data);
			if(X-g_area <= g_User_X[i] < X+g_area && Y-g_area <= g_User_Y[i] < Y+g_area && Z-g_area <= g_User_Z[i] < Z+g_area){
				FT_SD_Punish(name);
				}
			else{
				return PLUGIN_CONTINUE;
				}
		    }
	    }
    }

    // If bot protection is on (which it should be), the bot won't get kicked, but announce to people that we tried
    get_userAuthID(name,AuthIDi,MAX_AUTHID_LENGTH);
    if (strcmp(AuthIDi,"BOT")!=1){
        snprintf(Text, MAX_TEXT_LENGTH, "[Server-Message] The Bot, %s, just spawn damaged...", name);
        typesay(Text, DISPLAY_TIME, DISPLAY_RED, DISPLAY_GREEN, DISPLAY_BLUE);
    }

    // If an admin just did the killing, shame (since it probably didn't punish the player depending on the immunity cvar
    else if (access(ACCESS_IMMUNITY,name)!=0){
        snprintf(Text, MAX_TEXT_LENGTH, "[Server-Message] The (Co-)Admin, %s, just spawn damaged...", name);
        typesay(Text, DISPLAY_TIME, DISPLAY_RED, DISPLAY_GREEN, DISPLAY_BLUE);
    }

    else{
        snprintf(Text, MAX_TEXT_LENGTH, "[Server-Message] %s is slayed for Spawn-Wallshooting!", name);
        typesay(Text, DISPLAY_TIME, DISPLAY_RED, DISPLAY_GREEN, DISPLAY_BLUE);
    }

    if ( g_Announce_Time == 1 )
    {
        if ( g_Spawn_Time == 1 )
          snprintf(Text, MAX_TEXT_LENGTH, "Spawn-Wallshooting is any damage before %i second into the match.", g_Spawn_Time);
	else
          snprintf(Text, MAX_TEXT_LENGTH, "Spawn-Wallshooting is any damage before %i seconds into the match.", g_Spawn_Time);
        typesay(Text, DISPLAY_TIME, DISPLAY_RED, DISPLAY_GREEN, DISPLAY_BLUE);
    }
    return PLUGIN_CONTINUE;
}

/* *******************************************************************
    This function runs when the round begins or end (thanks to LogD)
   ******************************************************************* */
public FTLogdWorldAction(HLCommand,HLData,HLUserName,UserIndex)
{
	new Data[MAX_DATA_LENGTH];
	new i;
	new maxplayers=maxplayercount();
	new Player[MAX_NAME_LENGTH];
	convert_string(HLData,Data,MAX_DATA_LENGTH);
	if(Data[0]=='G' || Data[8]=='R'){
		reset(0);
	}else if (Data[6]=='E'){
		reset(0);
	}else if (Data[6]=='S'){
		for(i=1;i<=maxplayers;i++){
			if(playerinfo(i,Player,MAX_NAME_LENGTH)){
				get_userorigin(Player,g_User_X[i],g_User_Y[i],g_User_Z[i]);
			}
		}
		g_SDStart = systemtime();
	}
	return PLUGIN_CONTINUE;
}


/*********************************************************
 *                 COMMAND HANDLERS                      *
 *********************************************************
*/

public ft_sd_spawn_time(HLCommand,HLData,HLUserName,UserIndex) {
    new Text[MAX_TEXT_LENGTH] = "";
    new Data[MAX_DATA_LENGTH];
    new numData;

    convert_string(HLData,Data,MAX_DATA_LENGTH);

    numData = strtonum(Data);
    if (strlen(Data) <= 0)
    {
        snprintf(Text, MAX_TEXT_LENGTH, "ft_sd_spawn_time is set to: %i seconds", g_Spawn_Time);
        selfmessage(Text);
    }
    //else if ( (numData < 0) || numData > ( getvar("mp_roundtime") - getvar("mp_freezetime") ) )
    else if ( (numData < 0) || (numData > MAX_SPAWN_TIME) )
    {
        snprintf(Text, MAX_TEXT_LENGTH, "Bad data: %s", Data);
        selfmessage(Text);
    }
    else
    {
        g_Spawn_Time = numData;
        snprintf(Text, MAX_TEXT_LENGTH, "ft_sd_spawn_time is now set to: %i seconds", g_Spawn_Time);
        selfmessage(Text);
    }

    return PLUGIN_HANDLED;
}

public ft_sd_type(HLCommand,HLData,HLUserName,UserIndex) {
    new Text[MAX_TEXT_LENGTH] = "";
    new Data[MAX_DATA_LENGTH];
    new numData;

    convert_string(HLData,Data,MAX_DATA_LENGTH);

    numData = strtonum(Data);
    if (strlen(Data) <= 0)
    {
        snprintf(Text, MAX_TEXT_LENGTH, "ft_sd_type is set to: %i", g_Type);
        selfmessage(Text);
    }
    else if ( (numData < 0) || (numData > 3) )
    {
        //snprintf(Text, MAX_TEXT_LENGTH, "Bad data: %s", Data);
        //selfmessage(Text);
    }
    else
    {
        g_Type = numData;
        snprintf(Text, MAX_TEXT_LENGTH, "ft_sd_type is now set to: %i", g_Type);
        selfmessage(Text);
    }

    return PLUGIN_HANDLED;
}

public ft_sd_announce_time(HLCommand,HLData,HLUserName,UserIndex) {
    new Text[MAX_TEXT_LENGTH] = "";
    new Data[MAX_DATA_LENGTH];
    new numData;

    convert_string(HLData,Data,MAX_DATA_LENGTH);

    numData = strtonum(Data);
    if (strlen(Data) <= 0)
    {
        snprintf(Text, MAX_TEXT_LENGTH, "ft_sd_announce_time is set to: %i", g_Announce_Time);
        selfmessage(Text);
    }
    else if ( (numData < 0) || (numData > 1) )
    {
        //snprintf(Text, MAX_TEXT_LENGTH, "Bad data: %s", Data);
        //selfmessage(Text);
    }
    else
    {
        g_Spawn_Time = numData;
        snprintf(Text, MAX_TEXT_LENGTH, "ft_sd_announce_time is now set to: %i", g_Announce_Time);
        selfmessage(Text);
    }

    return PLUGIN_HANDLED;
}

public ft_sd_area(HLCommand,HLData,HLUserName,UserIndex) {
	new Command[MAX_COMMAND_LENGTH];
	new Data[MAX_DATA_LENGTH];
	new User[MAX_NAME_LENGTH];
	new Text[MAX_TEXT_LENGTH];
	convert_string(HLCommand,Command,MAX_COMMAND_LENGTH);
	convert_string(HLData,Data,MAX_DATA_LENGTH);
	convert_string(HLUserName,User,MAX_NAME_LENGTH);
	new temp_tol=0;
	if (strlen(Data)==0) {
		snprintf(Text,MAX_TEXT_LENGTH,"SD-Area: %i",g_area);
		selfmessage(Text);
	} else{
		temp_tol=strtonum(Data);
		g_area=temp_tol;
		snprintf(Text,MAX_TEXT_LENGTH,"SD-Area: %i",g_area);
		selfmessage(Text);
	}
	new NumString[MAX_TEXT_LENGTH];
	numtostr(g_area,NumString);
	set_vaultdata("admin_sd_area",NumString);
	say_command(User,Command,Data);
	return PLUGIN_HANDLED;
}

/*********************************************************
 *                 PLUGIN INITIALIZATION                 *
 *********************************************************
*/
public plugin_init() {
    plugin_registerinfo("Spawn Damage Plugin","Punish players who damage right after the freeze time is over",STRING_VERSION);
    plugin_registercmd("admin_sd_spawn_time","ft_sd_spawn_time",ACCESS_RCON,"admin_sd_spawn_time: Time (in sec) (after buytime) when a damage is a spawn damage");
    plugin_registercmd("admin_sd_announce_time","ft_sd_announce_time",ACCESS_RCON,"admin_sd_announce_time: Announce the spawn time after a spawn punish? (1=yes, 0=no)");
    plugin_registercmd("admin_sd_type","ft_sd_type",ACCESS_RCON,"admin_sd_type: How the spawn shooter should be punished (0-3) (see docs for values)");
    plugin_registercmd("admin_sd_area","ft_sd_area",ACCESS_RCON,"admin_sd_area <area> Sets/displays SD-Area in units.");

    plugin_registercmd("ft_sd_logdwa","FTLogdWorldAction",ACCESS_CONSOLE,"");
    // 62 is round start/end event
    exec("logd_reg 62 admin_command ft_sd_logdwa");
    // 58 is a damage event
    plugin_registercmd("ft_sd_logdda","FTLogdDamage",ACCESS_CONSOLE,"");
    exec("logd_reg 58 admin_command ft_sd_logdda" );

    if(!get_vaultnumdata("admin_sd_area",g_area)){
	g_area=40;
        set_vaultnumdata("admin_sd_area",g_area);
    }

    return PLUGIN_CONTINUE;

}
Wäre super wenn da ein Profi mal draufgucken könnte, wir können das Plugin echt gut gebrauchen !

THX!

CU, Belzebub (Kai)

Autor:  [WING] Black Knight [ 24.04.2006, 19:07 ]
Betreff des Beitrags: 

Ein Spawndamage-Plugin hatte Sir Drink a lot wohl mal gemacht. Nichtsdestotrotz sieht der entsprechende Code eigentlich ganz gut aus, so dass ich vorerst mal von einem LogD-Problem ausgehen möchte. Sicher, dass LogD richtig installiert ist? Manchmal vergisst man das bei der Installation eines Testservers. ;)

Hast Du es mal mit einem Debug-Logeintrag versucht?
Code:
get_userorigin(Player,g_User_X[i],g_User_Y[i],g_User_Z[i]);
snprintf(sData,MAX_DATA_LENGTH,"%s %d %d %d",Player,g_User_X[i],g_User_Y[i],g_User_Z[i]);
log(sData);
Gibt er etwas aus? Wenn ja, wirklich 0?

Autor:  Belzebub [ 25.04.2006, 06:17 ]
Betreff des Beitrags: 

:D

Danke für dem Debug-Tip ! Habs hinbekommen!
Wer Interesse an das Plugin hat, kann sich ja hier melden !

CU Belzebub (Kai)

Autor:  [WING] Black Knight [ 25.04.2006, 16:45 ]
Betreff des Beitrags: 

Mit einer ordentlichen Readme können wir es auch veröffentlichen.

Autor:  Belzebub [ 26.04.2006, 01:13 ]
Betreff des Beitrags: 

Jo, falls Interesse besteht, bastel ich mal ne ReadMe zusammen ... ^^

Seite 1 von 1 Alle Zeiten sind UTC+01:00
Powered by phpBB® Forum Software © phpBB Limited
https://www.phpbb.com/