Hi @ all coders...
Ich habe ein Problem mit diesem Plugin "plugin_ejl_timebomb".
Ich möchte gerne, dieses Plugin bei Neustart oder bei Mapchange des Servers auf 0 gesetzt haben, also deaktiviert. Ich habe es schon versucht den Eintrag "admin_timebombs 0" in der vault.ini, der server.cfg und der adminmod.cfg unterzubringen. Leider funzt es nicht, warum auch immer ??? Kann einer mir vielleicht helfen, da ich noch ein Newbie im compilieren bzw. coden bin. Welche Zeilen im Code müsste ich ändern ??Ich wäre Euch allen (Coding-Cracks) sehr dankbar...
Hier ist der Original-Code:
Code:
/***************************************************************************
* plugin_ejl_timebomb.sma release version 1.0 Date: 03/07/2002
* Author: Eric Lidman ejlmozart@hotmail.com
* Alias: Ludwig van Server: GNYSO-2
*
* COMMANDS:
*
* say: kamikaze
* admin_timebombs < 0 | 1 >
* admin_timebomb <target>
* admin_vote_timebomb <target>
*
* Player can become a timebomb by saying "kamikazi" in chat. Admin can
* disable the kamikaze function with admin_timebombs 0 and turn it back
* on again with admin_timebombs 1. Admin can make any live player without
* immunity into a timebomb with admin_timebomb <target>. All players can
* start a vote to turn a player into a timebomb in much the same way that
* admin_vote_map or admin_vote_kick works -- admin_vote_timebomb <target>
*
* THE DETAILS:
*
* Timer has a 15 second fuse. Countdown is done with half-life sounds.
* Bystanders will also die when bomb explodes.
* You know you are a bystander (or bomb) if you hear the C4 timer beep.
* No more than one player can be a timebomb at any given time.
* A timebomb player glows random colors during the countdown.
* Dead Players cannot become timebombs.
* There is a 5 minute delay between "kamikaze" runs for each player.
* A timebomb who dies before the end of countdown explodes one second
* after death, also killing bystanders.
*
* For more fun, make sure you have this in your server.cfg admin_fx 1
*
* Additional credit:
* This plugin is a very, very, very loose spinoff on plugin_sank_dice,
* which I heavily modified, and then tore down to make this plugin.
* So thanks to Luke Sankey for the basic structure, or whats left of it.
*
**************************************************************************/
#include <core>
#include <console>
#include <string>
#include <admin>
#include <adminlib>
////////////////////////////////////////////////////////////////////////////
//
// Change these values below to whatever you want, but I did alot of testing
// and I think they are actually best left alone.
//
////////////////////////////////////////////////////////////////////////////
// Sets the bomb's kill radius (default 500)(key = playerheight is about 95)
new BOMBKILL_RANGE = 500;
// Sets the timelimit between kamikaze runs for a player. (default 300 sec.)
#define TIMEBOMBER_DELAY 300
// Sets the vote ratio required to pass a timebomb vote (default 70 percent)
#define TIMEBOMB_VOTE_RATIO 70
// Who can call a timebomb vote (default 1 = everyone)
#define ACCESS_VOTE_TIMEBOMB 1
// Admin access required to use admin_timebomb <target> and admin_timebombs
#define ACCESS_TIMEBOMB 128
// TIMER fuse time (not intended to be set below 15)
#define TIMEBOMBER_TIME 15
/////////////////////////////////////////////////////////////////////////////
//
// Dont bother editing blow this point unless you know what you are doing.
// Its ok, however, change the messages between quotation marks if you want.
//
/////////////////////////////////////////////////////////////////////////////
new STRING_VERSION[MAX_DATA_LENGTH] = "2.50";
new bool:bIsBombing = false;
new LastBombTime[MAX_PLAYERS+1];
new bool:bBombsEnabled = true;
new LastBombedName[MAX_NAME_LENGTH];
new LastBomberIndex = 0;
new iTimebombed_Timer = 0;
new BlowemUpEarly = 0;
new BombRightGuy;
public plugin_init()
{
plugin_registerinfo("Human Time-Bomb Plugin", "say: kamakaze", STRING_VERSION);
plugin_registercmd("admin_timebombs", "admin_timebombs", ACCESS_TIMEBOMB, "admin_timebombs <on|off>: Controls whether players can kamikaze.");
plugin_registercmd("admin_timebomb", "admin_timebomb", ACCESS_TIMEBOMB, "admin_timebomb <target>: Turns player into time-bomb.");
plugin_registercmd("admin_vote_timebomb","admin_vote_timebomb",ACCESS_VOTE_TIMEBOMB,"admin_vote_timebomb <target>: Starts a vote to turn a target into a timebomb.");
plugin_registercmd("say", "HandleSay", ACCESS_ALL);
return PLUGIN_CONTINUE;
}
// I dont know precisely what this "plugin_connect" does, but sank_dice had it and thats what mine is based on.
public plugin_connect(HLUserName, HLIP, UserIndex)
{
if (UserIndex >= 1 && UserIndex <= MAX_PLAYERS)
LastBombTime[UserIndex] = 0;
return PLUGIN_CONTINUE;
}
public admin_timebombs(HLCommand, HLData, HLUserName, UserIndex)
{
new Data[MAX_DATA_LENGTH];
new User[MAX_NAME_LENGTH];
new Text[MAX_TEXT_LENGTH];
new Red = random(256);
new Green = random(256);
new Blue = random(256);
convert_string(HLData, Data, MAX_COMMAND_LENGTH);
convert_string(HLUserName, User, MAX_NAME_LENGTH);
if (check_param(Data) == 1)
{
bBombsEnabled = true;
snprintf(Text, MAX_TEXT_LENGTH, "Ok, lets kamikaze!");
centersay(Text, 5, Red, Green, Blue);
}
else
{
bBombsEnabled = false;
snprintf(Text, MAX_TEXT_LENGTH, "No more kamikazes.");
centersay(Text, 5, Red, Green, Blue);
}
snprintf(Text, MAX_TEXT_LENGTH, "admin_timebombs %d", bBombsEnabled);
selfmessage(Text);
return PLUGIN_HANDLED;
}
public admin_timebomb(HLCommand, HLData, HLUserName, UserIndex)
{
new Data[MAX_DATA_LENGTH];
new User[MAX_NAME_LENGTH];
new Text[MAX_TEXT_LENGTH];
new TargetName[MAX_NAME_LENGTH];
new Command[MAX_COMMAND_LENGTH];
new BombGuy[MAX_DATA_LENGTH];
new Name[MAX_NAME_LENGTH];
new SessionID, WONID;
new UserTeam, UserDead;
new TargetIndex;
new Red = random(256);
new Green = random(256);
new Blue = random(256);
convert_string(HLData, Data, MAX_DATA_LENGTH);
convert_string(HLUserName, User, MAX_NAME_LENGTH);
convert_string(HLCommand,Command,MAX_COMMAND_LENGTH);
// is anyone else a bomb?
if (bIsBombing == true)
{
selfmessage("Someone else is a time-bomb now, please wait.");
return PLUGIN_CONTINUE;
}
// no, then we can check some more things
else{
if (check_user(Data) == 1) {
get_username(Data,TargetName,MAX_NAME_LENGTH);
get_userindex(Data,TargetIndex);
strcpy(BombGuy, TargetName, MAX_NAME_LENGTH);
if (UserIndex != LastBomberIndex || streq(LastBombedName, TargetName) == 0) {
say_command(User,Command,TargetName);
}
if(check_immunity(TargetName)!=0) {
snprintf(Text, MAX_TEXT_LENGTH, "Laf. You can't turn %s into a time-bomb, you silly bear.", TargetName);
messageex(User, Text, print_chat);
return PLUGIN_CONTINUE;
}
// we check to see if the target is a dead player and exit the plugin if dead
if (playerinfo(TargetIndex, Name, MAX_NAME_LENGTH, SessionID, WONID, UserTeam, UserDead)){
if (UserDead != 0){
snprintf(Text, MAX_TEXT_LENGTH, "You can't turn %s into a time-bomb, he is already dead.", TargetName);
messageex(User, Text, print_chat);
return PLUGIN_CONTINUE;
}
// ok, now we are making a bomb because our target is alive and not immune
else if (UserDead !=1){
// BombRightGuy: I had problems name changing while they were bombs, this solved it (userindex).
BombRightGuy = TargetIndex;
snprintf(Text, MAX_TEXT_LENGTH, "%s has turned %s into a human time-bomb.", User, TargetName);
say(Text);
snprintf(Text, MAX_TEXT_LENGTH, "%s will explode in 10 seconds", TargetName);
typesay(Text, 1, Red, Green, Blue);
glow(TargetName, Red, Green, Blue);
bIsBombing = true;
new i;
new iMaxPlayers = maxplayercount();
for (i = 1; i <= iMaxPlayers; i++) {
if (playerinfo(i,Name,MAX_NAME_LENGTH) == 1) {
execclient(Name, "speak ^"warning _comma detonation device activated^"");
}
}
iTimebombed_Timer = set_timer("Timebombed_Timer", 1, TIMEBOMBER_TIME, BombGuy);
LastBomberIndex = UserIndex;
}
else {
selfmessage("Unrecognized player: ");
selfmessage(Data);
}
}
return PLUGIN_CONTINUE;
}
}
return PLUGIN_CONTINUE;
}
public HandleSay(HLCommand, HLData, HLUserName, UserIndex)
{
new Data[MAX_DATA_LENGTH];
new User[MAX_NAME_LENGTH];
new Text[MAX_TEXT_LENGTH];
new BombGuy[MAX_NAME_LENGTH];
new Red = random(256);
new Green = random(256);
new Blue = random(256);
convert_string(HLData, Data, MAX_DATA_LENGTH);
convert_string(HLUserName, User, MAX_NAME_LENGTH);
strcpy(BombGuy, User, MAX_DATA_LENGTH);
// Remove quotes, if there are any
strstripquotes(Data);
// here is what we have to say to become a bomb -- any loose spelling of "kamikaze"
// also we check to make sure admin didnt disable kamikaze runs
if ( ((strcasestr(Data, "kamik") != -1) || (strcasestr(Data, "kamak") != -1))
&& (bBombsEnabled == true) )
{
new Name[MAX_NAME_LENGTH];
new SessionID, WONID;
new UserTeam, UserDead;
if (playerinfo(UserIndex, Name, MAX_NAME_LENGTH, SessionID, WONID, UserTeam, UserDead)){
if (UserDead != 0){
messageex(User, "<Server> You cant be a time-bomb, you are dead already.", print_chat);
return PLUGIN_CONTINUE;
}
else if (UserDead !=1){
new CurTime = systemtime();
// Limit bombing frequency
if (CurTime < (LastBombTime[UserIndex] + TIMEBOMBER_DELAY))
{
messageex(User, "<Server> Sorry, there is a 5 minute delay between your bombings.", print_chat);
return PLUGIN_CONTINUE;
}
else if (bIsBombing == true)
{
messageex(User, "<Server> Someone else is a time-bomb now, please wait.", print_chat);
return PLUGIN_CONTINUE;
}
else
{
// Being the Bomb -- just like above
BombRightGuy = UserIndex;
snprintf(Text, MAX_TEXT_LENGTH, "<Server> %s has become a human time-bomb. Everyone RUN for cover!", User);
say(Text);
snprintf(Text, MAX_TEXT_LENGTH, "%s will explode in %i seconds", User, TIMEBOMBER_TIME);
typesay(Text, 1, Red, Green, Blue);
glow(User, Red, Green, Blue);
bIsBombing = true;
new i;
new iMaxPlayers = maxplayercount();
for (i = 1; i <= iMaxPlayers; i++) {
if (playerinfo(i,Name,MAX_NAME_LENGTH) == 1) {
execclient(Name, "speak ^"warning _comma detonation device activated^"");
}
}
iTimebombed_Timer = set_timer("Timebombed_Timer", 1, TIMEBOMBER_TIME, BombGuy);
LastBombTime[UserIndex] = CurTime;
}
}
return PLUGIN_CONTINUE;
}
}
return PLUGIN_CONTINUE;
}
public admin_vote_timebomb(HLCommand,HLData,HLUserName,UserIndex) {
new Command[MAX_COMMAND_LENGTH];
new Data[MAX_DATA_LENGTH];
new Text[MAX_TEXT_LENGTH];
new User[MAX_NAME_LENGTH];
new WONID;
new strWONID[MAX_NUMBER_LENGTH];
new Name[MAX_NAME_LENGTH];
new SessionID, infoWONID;
new UserTeam, UserDead;
new TargetIndex;
if (vote_allowed()!=1) {
selfmessage( "Vote not allowed at this time.");
return PLUGIN_HANDLED;
}
// is anyone else a bomb?
if (bIsBombing == true){
selfmessage("Someone else is a time-bomb now, please wait.");
return PLUGIN_CONTINUE;
}
convert_string(HLCommand,Command,MAX_COMMAND_LENGTH);
convert_string(HLData,Data,MAX_DATA_LENGTH);
convert_string(HLUserName,User,MAX_NAME_LENGTH);
if (check_user(Data) == 1) {
new real_user[MAX_NAME_LENGTH];
get_username(Data,real_user,MAX_NAME_LENGTH);
say_command(User,Command,Data);
if(check_immunity(real_user)!=0) {
snprintf(Text, MAX_TEXT_LENGTH, "Laf. You can't turn %s into a timebomb you silly bear.", real_user);
say(Text);
} else {
// we check to see if the target is a dead player and exit if dead
get_userindex(Data,TargetIndex);
if (playerinfo(TargetIndex, Name, MAX_NAME_LENGTH, SessionID, infoWONID, UserTeam, UserDead)){
if (UserDead != 0){
snprintf(Text, MAX_TEXT_LENGTH, "You can't turn %s into a time-bomb, he is already dead.", real_user);
say(Text);
return PLUGIN_CONTINUE;
}
}
BombRightGuy = TargetIndex;
bIsBombing = true;
snprintf(Text, MAX_TEXT_LENGTH, "Should we blow up %s?", real_user);
if(getvar("sv_lan")==1) {
vote(Text,"Yes","No","HandleBombVote",real_user);
} else {
get_userWONID(real_user,WONID);
numtostr(WONID,strWONID);
vote(Text,"Yes","No","HandleBombVote",strWONID);
}
}
} else {
selfmessage("Unrecognized user name ");
selfmessage(Data);
}
return PLUGIN_HANDLED;
}
/* Handle a timebomb vote's results. */
public HandleBombVote(WinningOption,HLUser,VoteCount,UserCount) {
new strNumber[MAX_NUMBER_LENGTH];
new Text[MAX_TEXT_LENGTH];
new VoteUser[MAX_DATA_LENGTH];
new BombGuy[MAX_DATA_LENGTH];
new Name[MAX_NAME_LENGTH];
new SessionID, WONID;
new UserTeam, UserDead;
new Red = random(256);
new Green = random(256);
new Blue = random(256);
convert_string(HLUser,VoteUser,MAX_DATA_LENGTH);
strcpy(BombGuy, VoteUser, MAX_NAME_LENGTH);
if (WinningOption == 1) {
new Ratio = TIMEBOMB_VOTE_RATIO;
if (VoteCount >= Ratio*UserCount/100) {
// we check to see if the target is a dead player and exit the plugin if dead
if (playerinfo(BombRightGuy, Name, MAX_NAME_LENGTH, SessionID, WONID, UserTeam, UserDead)){
strcpy(VoteUser, Name, MAX_NAME_LENGTH);
if (UserDead != 0){
snprintf(Text, MAX_TEXT_LENGTH, "<Server> Can't turn %s into a time-bomb, he died already.", VoteUser);
say(Text);
bIsBombing = false;
BlowemUpEarly = 0;
BombRightGuy = 0;
return PLUGIN_CONTINUE;
}
// ok, now we are making a bomb because our target is alive and not immune
else if (UserDead !=1){
snprintf(Text, MAX_TEXT_LENGTH, "%s will explode in %i seconds", VoteUser,TIMEBOMBER_TIME);
typesay(Text, 1, Red, Green, Blue);
glow(VoteUser, Red, Green, Blue);
new i;
new iMaxPlayers = maxplayercount();
for (i = 1; i <= iMaxPlayers; i++) {
if (playerinfo(i,Name,MAX_NAME_LENGTH) == 1) {
execclient(Name, "speak ^"warning _comma detonation device activated^"");
}
}
snprintf(Text, MAX_TEXT_LENGTH, "%s was turned into a timebomb due to a vote.", VoteUser);
say(Text);
message(Name,"You have been turned into a timebomb due to a vote.");
iTimebombed_Timer = set_timer("Timebombed_Timer", 1, TIMEBOMBER_TIME, BombGuy);
}
}
else {
selfmessage("Unrecognized player: ");
selfmessage(VoteUser);
}
} else {
numtostr(Ratio*UserCount/100,strNumber);
bIsBombing = false;
BlowemUpEarly = 0;
BombRightGuy = 0;
snprintf(Text, MAX_TEXT_LENGTH, "Bomb vote succeeded, but not enough votes for bomb (needed %s)",strNumber);
say(Text);
}
} else {
bIsBombing = false;
BlowemUpEarly = 0;
BombRightGuy = 0;
say("Bomb vote failed.");
}
return PLUGIN_CONTINUE;
}
///***************************************************************************/
/// Here is the Timer Function , the heart of the timebomb
public Timebombed_Timer(Timer, Repeat, HLUserName, BombGuy)
{
new Text[MAX_TEXT_LENGTH];
new TargetBombName[MAX_NAME_LENGTH];
new TargetBomb[MAX_NAME_LENGTH];
new Countdown[MAX_TEXT_LENGTH];
new i;
new iMaxPlayers = maxplayercount();
new Name[MAX_NAME_LENGTH];
new COUNTSPEAK[MAX_TEXT_LENGTH];
new C4_SOUND[MAX_TEXT_LENGTH];
new C4_BEEP[MAX_TEXT_LENGTH];
new Dead;
new maxplayers = maxplayercount();
new SessionID;
new Team;
new WONID;
new x,y,z;
new X,Y,Z;
new Red = random(256);
new Green = random(256);
new Blue = random(256);
convert_string(BombGuy,TargetBomb,MAX_NAME_LENGTH);
// if a player dies before the countdown, we use this to kill the countdown and blow the bomb
// before I added this, a dead player in chase camera mode or free look mode could lock onto
// any live player and blow them up. It was fun, but not right. No more ghost bombers.
if (BlowemUpEarly == 1){
Repeat = 1;
}
// time to blow up
if (Repeat-1 == 0){
// loop to get everyones location in a map and decide whether they are too close to the bomb
// too close? well, kill em
for (i=1; i<=maxplayers; i++) {
if( playerinfo(i,Name,MAX_NAME_LENGTH,SessionID,WONID,Team,Dead)!=0){
// make sure we still have the right guy's name
if(i == BombRightGuy){
TargetBomb = Name;
}
// find everyone X is bomb, x is everyone else (one at a time)
get_userorigin(TargetBomb, X, Y, Z);
get_userorigin(Name,x,y,z);
if( ! (X-x > BOMBKILL_RANGE || X-x < - BOMBKILL_RANGE ||
Y-y > BOMBKILL_RANGE || Y-y < - BOMBKILL_RANGE ||
Z-z > BOMBKILL_RANGE || Z-z < - BOMBKILL_RANGE) ){
if(Dead==0) {
messageex(Name, "<Server> Sorry, the bomb killed you.", print_chat);
slay(Name);
}
}
}
}
get_username(TargetBomb,TargetBombName,MAX_NAME_LENGTH);
glow(TargetBomb, 0, 0, 0);
snprintf(Text, MAX_TEXT_LENGTH, "%s has exploded.", TargetBombName);
typesay(Text, 1, Red, Green, Blue);
bIsBombing = false;
BlowemUpEarly = 0;
BombRightGuy = 0;
kill_timer(iTimebombed_Timer);
}
else
{
// find out if the bomb guy is dead and set blowupearly to 1 if he is dead
// but make sure we have the right guy first
if (Repeat >= 13){
for (i = 1; i <= iMaxPlayers; i++) {
if (playerinfo(i,Name,MAX_NAME_LENGTH, SessionID, WONID, Team, Dead) == 1) {
if(i == BombRightGuy){
TargetBomb = Name;
}
if (!strcmp(TargetBomb, Name)){
if (Dead != 0){
BlowemUpEarly = 1;
}
}
// find everyone X is bomb, x is everyone else (one at a time)
// tells who should hear the c4 timer and then makes them hear it
get_userorigin(TargetBomb, X, Y, Z);
get_userorigin(Name,x,y,z);
if( ! (X-x > BOMBKILL_RANGE || X-x < - BOMBKILL_RANGE ||
Y-y > BOMBKILL_RANGE || Y-y < - BOMBKILL_RANGE ||
Z-z > BOMBKILL_RANGE || Z-z < - BOMBKILL_RANGE) ){
playsound(Name, "weapons/c4_beep1.wav");
}
}
}
get_username(TargetBomb,TargetBombName,MAX_NAME_LENGTH);
glow(TargetBomb, Red, Green, Blue);
snprintf(Text, MAX_TEXT_LENGTH, "%s will explode in %d", TargetBombName, Repeat-1);
typesay(Text, 1, Red, Green, Blue);
return PLUGIN_CONTINUE;
}
// I love this countdown. here is where we tell half-life what words to speak
// C4 timer sound gets more intense as countdown nears completion
if (Repeat == 12){
strcpy(Countdown, "remaining", 20);
strcpy(C4_BEEP, "weapons/c4_beep1.wav", 30);
}
if (Repeat == 11){
strcpy(Countdown, "ten", 10);
strcpy(C4_BEEP, "weapons/c4_beep1.wav", 30);
}
if (Repeat == 10){
strcpy(Countdown, "nine", 10);
strcpy(C4_BEEP, "weapons/c4_beep1.wav", 30);
}
if (Repeat == 9){
strcpy(Countdown, "eight", 10);
strcpy(C4_BEEP, "weapons/c4_beep1.wav", 30);
}
if (Repeat == 8){
strcpy(Countdown, "seven", 10);
strcpy(C4_BEEP, "weapons/c4_beep2.wav", 30);
}
if (Repeat == 7){
strcpy(Countdown, "six", 10);
strcpy(C4_BEEP, "weapons/c4_beep2.wav", 30);
}
if (Repeat == 6){
strcpy(Countdown, "five", 10);
strcpy(C4_BEEP, "weapons/c4_beep4.wav", 30);
}
if (Repeat == 5){
strcpy(Countdown, "four", 10);
strcpy(C4_BEEP, "weapons/c4_beep4.wav", 30);
}
if (Repeat == 4){
strcpy(Countdown, "three", 10);
strcpy(C4_BEEP, "weapons/c4_beep4.wav", 30);
}
if (Repeat == 3){
strcpy(Countdown, "two", 10);
strcpy(C4_BEEP, "weapons/c4_beep5.wav", 30);
}
if (Repeat == 2){
strcpy(Countdown, "one", 10);
strcpy(C4_BEEP, "weapons/c4_beep5.wav", 30);
}
if (Repeat == 1){
return PLUGIN_CONTINUE;
}
snprintf(COUNTSPEAK, MAX_DATA_LENGTH, "speak ^"fvox/%s^"", Countdown);
snprintf(C4_SOUND, MAX_DATA_LENGTH, "^"%s^"", C4_BEEP);
for (i = 1; i <= iMaxPlayers; i++) {
if (playerinfo(i,Name,MAX_NAME_LENGTH, SessionID, WONID, Team, Dead) == 1) {
// we gotta make sure we got the right guy
if(i == BombRightGuy){
TargetBomb = Name;
}
// if he is dead, blow him up early, we dont want spectators ghost bombing
if (!strcmp(TargetBomb, Name)){
// ok, is bomber dead early? if so, set blowemup early to 1 = so next pass we blow up.
if (Dead != 0){
BlowemUpEarly = 1;
}
}
// find everyone X is bomb, x is everyone else (one at a time)
// find out who should hear the c4 timer sound then make them hear it
get_userorigin(TargetBomb, X, Y, Z);
get_userorigin(Name,x,y,z);
if( ! (X-x > BOMBKILL_RANGE || X-x < - BOMBKILL_RANGE ||
Y-y > BOMBKILL_RANGE || Y-y < - BOMBKILL_RANGE ||
Z-z > BOMBKILL_RANGE || Z-z < - BOMBKILL_RANGE) ){
playsound(Name, C4_SOUND);
}
execclient(Name, COUNTSPEAK);
}
}
get_username(TargetBomb,TargetBombName,MAX_NAME_LENGTH);
glow(TargetBomb, Red, Green, Blue);
snprintf(Text, MAX_TEXT_LENGTH, "%s will explode in %d", TargetBombName, Repeat-1);
typesay(Text, 1, Red, Green, Blue);
}
return PLUGIN_CONTINUE;
}