Raised This Month: $ Target: $400
 0% 

round_start isn't called in NMRiH


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ELITE_eNergizer
Member
Join Date: Jan 2008
Old 11-03-2013 , 01:12   round_start isn't called in NMRiH
Reply With Quote #1

This plugin is being scripted for No More Room in Hell.

Read my plugin description to get the jist of what I'm trying to make.

Basically I want to make this plugin for NMRiH, but the main problem is that the event round_start isn't even being called in the mod.

Code:
#include <sourcemod>
#include <sdktools>

public Plugin:myinfo =
{
    name = "Kill Players ",
    author = "DrPastah",
    description = "Kills players after a countdown if a certain dead player ratio is reached when it's late into the game.",
    version = "0.1",
    url = "http://www.sourcemod.net/"
};

static deadPlayers;
static bool:lateInGame;
static connectedPlayers;
static Handle:killTimer;
static Handle:messageTimer;

public OnPluginStart()
{
    HookEvent("player_connect", Event_PlayerConnect, EventHookMode_Pre);
    HookEvent("player_disconnect", Event_PlayerDisconnect, EventHookMode_Pre);
    HookEvent("round_start", Event_RoundStart, EventHookMode_Pre);
    HookEvent("player_death", Event_PlayerDeath, EventHookMode_Pre);
}

/**
* These two functions will help with counting the amount of connected players
**/
public Action:Event_PlayerConnect(Handle:event, const String:name[], bool:dontBroadcast)
{
    connectedPlayers++;
}
// Read above
public Action:Event_PlayerDisconnect(Handle:event, const String:name[], bool:dontBroadcast)
{
    connectedPlayers--;
}

/**
* Make the flag true to signify that it is past the time interval which makes
* it late into the game
**/
public Action:StartChecking(Handle:timer)
{
    lateInGame = true;
}

/**
* To reset the count of dead players when a round starts
**/
public Action:Event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
{
    PrintToServer("Round Started");
    PrintToChatAll("Round Started");
    
    // Clean up some timers just in case
    KillTimer(killTimer, false);
    KillTimer(messageTimer, false);
    
    deadPlayers = 0;
    lateInGame = false;
    CreateTimer(60.0, StartChecking);
    
    return Plugin_Continue;
}

/**
* If it is late into the game, check our dead player ratio
* If the dead player ratio is too high, then kill off the rest of the players after a countdown
**/
public Action:Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
    deadPlayers++;
    
    if (!lateInGame)
        return Plugin_Continue;
    
    // Players will die in 1 min
    new Float:time = 60.0;
    if (deadPlayers > connectedPlayers/2)
    {
        PrintToChatAll("1 minute until survivors get wiped out.");
        killTimer = CreateTimer(time, KillPlayers);
        messageTimer = CreateTimer(time - 10, ChatTimerTime, 10);
    }
    
    return Plugin_Continue;
}

/**
* This function kills all players
**/
public Action:KillPlayers(Handle:timer)
{
    for (new i = 1; i <= MAXPLAYERS; i++)
        ForcePlayerSuicide(i);
}

/**
* This will print to the chat to everyone the index i until 0
**/
public Action:ChatTimerTime(Handle:timer, any:i)
{
    PrintToChatAll("%d", i--);
    if (i > 0)
        messageTimer = CreateTimer(i, ChatTimerTime, i);
}
ELITE_eNergizer is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 11-03-2013 , 01:32   Re: round_start isn't called in NMRiH
Reply With Quote #2

Check the game's modevents.res and see if it has a different round start event, such as teamplay_round_start (which is what TF2 uses).
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
ELITE_eNergizer
Member
Join Date: Jan 2008
Old 11-03-2013 , 01:43   Re: round_start isn't called in NMRiH
Reply With Quote #3

Quote:
Originally Posted by Powerlord View Post
Check the game's modevents.res and see if it has a different round start event, such as teamplay_round_start (which is what TF2 uses).
Thanks

EDIT:

Also I noticed that my countdown ChatToAll does the 10..9..8......1 really quickly at the last moment. Anyone know why?

Last edited by ELITE_eNergizer; 11-03-2013 at 02:57.
ELITE_eNergizer is offline
ELITE_eNergizer
Member
Join Date: Jan 2008
Old 11-03-2013 , 02:59   Re: round_start isn't called in NMRiH
Reply With Quote #4

Also sometimes this doesn't kill all players:

Code:
for (new i = 1; i <= MAXPLAYERS; i++)
        ForcePlayerSuicide(i);
ELITE_eNergizer is offline
GsiX
gee, six eggs
Join Date: Aug 2012
Location: Land Below The Wind
Old 11-03-2013 , 05:30   Re: round_start isn't called in NMRiH
Reply With Quote #5

Quote:
Originally Posted by ELITE_eNergizer View Post
Thanks

EDIT:

Also I noticed that my countdown ChatToAll does the 10..9..8......1 really quickly at the last moment. Anyone know why?
Of coz, you are using loop to kill all player.. of coz its count down fast and furious.

EDIT: Did you write this script?
__________________
If i happen to insulted you unintentionally,
it was me and Google Translate who did it.

Last edited by GsiX; 11-03-2013 at 05:31.
GsiX is offline
ELITE_eNergizer
Member
Join Date: Jan 2008
Old 11-03-2013 , 06:23   Re: round_start isn't called in NMRiH
Reply With Quote #6

Quote:
Originally Posted by GsiX View Post
Of coz, you are using loop to kill all player.. of coz its count down fast and furious.

EDIT: Did you write this script?
I did.

I changed my plugin around and I got most of it working except for the timer not stopping.

Code:
/**
* This will print to the chat to everyone the integer i until 0
**/
public Action:ChatTimerTime(Handle:timer)
{
    if (timeLeft > 60 && (timeLeft % 60 == 0) )
    {
        PrintCenterTextAll("%d minutes left", timeLeft/60);
    }
    else if (timeLeft <= 30)
    {
        PrintCenterTextAll("%d seconds left", timeLeft);
    }
    timeLeft -= 1;
    if (timeLeft < 1)
    {
        KillPlayers();
        return Plugin_Stop;
    }
return Plugin_Continue;
}
This is how I'm calling the timer:
Code:
CreateTimer( 1.0, ChatTimerTime, _, TIMER_REPEAT);
Why won't the timer stop repeating once it's below 1? It kills the players as it is supposed to.

Last edited by ELITE_eNergizer; 11-03-2013 at 06:40.
ELITE_eNergizer is offline
ELITE_eNergizer
Member
Join Date: Jan 2008
Old 11-03-2013 , 16:12   Re: round_start isn't called in NMRiH
Reply With Quote #7

I managed to fix the timer issue but for some reason it only worked by this method instead of the post above with return Plugin_Stop. Anyone know why this has happened?

Edit:
Actually I'm still having issues with the timer not stopping after decreasing below 1.

Code:
/**
* This will print to the center of the screen to everyone the timeLeft until 0
**/
public Action:ChatTimerTime(Handle:timer)
{
    if (timeLeft > 60 && (timeLeft % 60 == 0) )
    {
        PrintCenterTextAll("%d minutes left", timeLeft/60);
    }
    else if (timeLeft <= 30)
    {
        PrintCenterTextAll("%d seconds left", timeLeft);
    }
    timeLeft--;
    if (timeLeft < 1)
    {
        KillTimer(messageTimer);
        KillPlayers();
    }
}

Last edited by ELITE_eNergizer; 11-03-2013 at 16:24.
ELITE_eNergizer is offline
GsiX
gee, six eggs
Join Date: Aug 2012
Location: Land Below The Wind
Old 11-03-2013 , 23:56   Re: round_start isn't called in NMRiH
Reply With Quote #8

Where did you murder your timer..?
After map change?
After round end?

EDIT: Diu na seng lu..

Non repeat timer k'not be kill or murder...

Use Boolean to check if the round has end then do not execute what ever you trying to do inside the timer, instead return plugin_stop.
__________________
If i happen to insulted you unintentionally,
it was me and Google Translate who did it.

Last edited by GsiX; 11-03-2013 at 23:59.
GsiX is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 01:50.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode