Raised This Month: $241 Target: $400
 60% 

Notices

Objective Reset + Timer Control [V 0.1]


Post New Thread Reply   
 
Thread Tools Display Modes
Plugin Info:     Modification:   Counter-Strike        Category:   Gameplay       
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 08-08-2015 , 05:54   Objective Reset + Timer Control [V 0.1]
Reply With Quote #1

Objective Reset + Timer Control
Release: 08.08.2015 | Last Update: 08.08.2015

Table of Contents

Description top

I've worked in the last few weeks at one of my friends request, and it turned in a quite useful and nice plugin, so I decided to post it here. Basically, this plugin have two interconnected parts.
  • Reset the objective:
    • The ideea is that you can reset current round progress as it was at the beginning of the round. For mod like furien/fun/classic it is a nice addon.
    • All default objectives are supported(and can also work in maps with more than one objective):
      • Bomb: if planted, c4 will be removed and given a random player and the round will continue as per usual.
      • Hostages: hostages will be resetted to their old position, no matter if they were rescued/killed/somewhere in the map. When resetting, the number of rescue hostages is set to 0.
      • Vip: when the cmd is used another vip is choosed and he is send to spawn point. The old vip will become a normal player(so he can't trigger round end by reaching escape zone) and the new one get all attributes of a VIP.
      • Escape: I'm not quite sure about that one since I never played es_ maps before, if you want the plugin to do more on that scenario let me know. What it does for now is to reset the number of escapers and send them to tero base.
      • Timer: Reset the round timer as it was when round started(based on mp_roundtime cvar or mp_freezetime if in freezetime). The timer reset is handled as objective, but the command to alter the timer(add/remove seconds) not.
  • Control the round timer: the ideea is to make changes to round timer that will take effects immediately, it also support freeze time. If someone use the command in freezetime, then freeze will be alterated, else the round time will.

Requirements top

You need the fallowing things to get this working:
  • Orpheu module.
  • An updated server without dproto.
    It may work into your outdated server, but if it doesn't, I won't help, it can't do it even if I want to. Older builds require other signatures.
Installation top

To install the plugin:
  1. Download the resources from this post. You need to get the source and compile it locally.
  2. Put ObjectiveReset.amxx in addons/amxmodx/plugins
  3. Open addons/amxmodx/configs/plugins.ini and add at the end of this file ObjectiveReset.amxx
  4. You can put the sma file into addons/amxmodx/sources but this is not mandatory.
  5. Copy the content of addons/amxmodx/configs/orpheu from the archive to the same folder in your server(functions go to functions, memory to memory, and virtualFunctions to virtualFunctions)
  6. Restart the server/change map.

To install orpheu:
  1. Download orpheu_files-2.5.1.zip and extrat the arhive.
  2. Copy orpheu_amxx.dll/orpheu_amxx_i386.so depending on your operation system into addons/amxmodx/modules
  3. The module will be auto-loaded, you don't need to add it into modules.ini

To compile locally:
  • First way:
    1. Download AMX Mod X for windows/linux from main site
    2. Extract somewhere the arhive and remember the folder!
    3. Copy the content from include folder from the orpheu arhive into addons/amxmodx/scripting/include( in the folder created in the step 2 ).
    4. Get objective_reset.inc that is attached in the archive and put it inside include.
    5. Download the source of the plugin( ObjectiveReset_linux.sma) from this post and drag it over the compile.exe(scripting folder from the arhive created at step 2)
    6. It will create a new folder called compiled. Open it and you will find your compiled plugin( ObjectiveReset_linux.amxx )
  • Second way:
    1. Go to http://spider.limetech.org/
    2. Copy/paste the code from the .sma file into the website.
    3. Under the big blue Compile button you see a box which Drop .inc files here
    4. Then press Compile and Download
Commands top
  • ResetObjective
    • Valid types are:
      Code:
      timer/Timer/1 
      bomb/Bomb/2 
      vip/Vip/3
      hostages/Hostages/4 
      escape/Escape/5 
      detect/Detect/6
    • I've explained above what all of this resets, the name are intuitive. If you specify detect, then the objective will be auto-detected. In case of maps with more than one objective, the first found one will be returned.
    • For auto detection, the order of checking is: bomb -> hostages -> vip -> escape -> timer. In case no objective is found timer will be resetted.
    • Only the first letter is needed, so you can write b/h/v/e/d or the numbers and it will work.
    • Examples:
      Code:
      ResetObjective b  //reset bomb objective
      ResetObjective h  //reset hostage objective
      ResetObjective t  //reset timer objective
      ResetObjective e //reset escape objective
      ResetObjective d //automatically detect and reset the objective
  • SetRoundTime
    1. Param Time: this is the time(in seconds) that you want to set/add.
    2. Param Add: if 1 the time will be added to current round time, else it will set this time.
    3. When adding you can specify negative values so it will work like substracting.
    4. Examples:
      Code:
      SetRoundTime 10 0  //sets round time/freeze time to 10 seconds
      SetRoundTime 10 1  //add 10 seconds to current round time/ freeze time
      SetRoundTime -10 1 //substract 10 seconds from current round time/freeze time
    5. Changes take place immediately!
    6. If you try to specify a negative value when setting it will be handled as positive value.
  • GetRoundTime
    • This will print in player console the remained time from the round, in seconds.
Cvars top
  • OR_ShowChatMessage: 1 to notify players in chat that the objective was resetted/0 to do not.
  • OR_SendHookableCalls: If you don't know what you are doing, avoid this cvar please. This plugin calls some of game functions to do what id does, this functions may be hooked by other plugins. If this cvar is set to 1, every plugin that hook one of the function will know about this call and execute it's one code, if not it will be ignored. My reasoning behind this cvar was that you may run some incompatible plugins that supercede the hooks or whatever and you may want them to work at the same time, without interfering. As oposite, you may want your plugins to receive this calls and do something. Default value is 0. If 1 other plugins are noticed, if 0 they are not.
  • OR_SendReliableMessages: as above, please don't touch this cvar is you don't understand it's purpose or if it is not needed. A reliable message is send to player on reliable channel, and if you send too many messages the client will be disconnected. An unreliable message won't disconnect the client and won't be simply send if something went wrong(but you will get some gameplaye problems as round time not being updated correctly). If you experience some problems set this cvar to 0. 1 for reliable messages, 0 for unreliable.
API top

I will start by leaving here the include file:
PHP Code:
#if defined _objective_reset_included
    #endinput
#endif
#define _objective_reset_included

enum
{
    
Obj_InvalidObjective,
    
Obj_ResetTimer,
    
Obj_ResetBomb,
    
Obj_ResetVip,
    
Obj_ResetHostages,
    
Obj_ResetEscape,
    
Obj_DetectObjective
}

/**
    *  Reset the current objective(for objective index see the above enum)
    *
    *  @param Objective     The objective to restart.
    *  @return              1 if operation was succesfull, 0 otherwise
*/
native ResetObjective(Objective)

/**
    *  Alter the round time value.
    *
    *  @param Time    The time that will be used.
    *  @param Add     If 1 the time will be added to current time, 0 means set.
    *  @return        1 if operation was succesfull, 0 otherwise
*/
native SetRoundTime(const Time, const Add)

/**
    *  Return the value of round time/freeze time in seconds
    *
    *  @param         No params
    *  @return         Round time in seconds or -1 on failure        
*/
native GetRoundTime()

/**
        *  Send when an objective was resetted
        *
        *  @param Objective      The objective that was resetted.
        *  @return              Forward does not care about the return value
*/
forward OnObjectiveReset(const Objective)

/**
        *  Send when time is changed.
        *
        *  @param TimeType            1 if in freezetime, 0 otherwise
        *  @param OldRoundTime        The round time before change occured.
        *  @param NewRoundTime        The round time after change occured.
        *  @param RemainedTime        The remained time from the round.
        *  @return                   Forward does not care about the return value
*/
forward OnRoundTimeChanged(const TimeType, const OldRoundTime, const NewRoundTime, const RemainedTime
I believe everything is well documented and I won't explain again. Only one note, when using natives the message are still printed, but they go into server console, with one exception.
Credits top
  • Nubo: ideea + testing
  • ANTICHRISTUS: made wp for some maps so I was able to test
ChangeLog top
  • V 0.1: Initial release
Downloads top
  • V 0.1-
Attached Files
File Type: zip Objective Reset.zip (13.0 KB, 128 views)
File Type: inc objective_reset.inc (1.7 KB, 112 views)
File Type: sma Get Plugin or Get Source (ObjectiveReset.sma - 387 views - 23.3 KB)
__________________

Last edited by HamletEagle; 08-08-2015 at 09:37.
HamletEagle is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 08-08-2015 , 08:31   Re: Objective Reset + Timer Control [V 0.1]
Reply With Quote #2

Looks like you did not tested this under linux, the typo in get/set_pdata_bool stocks about linux extra offset is still there.
__________________
Working on : CS Weapon Mod (72%) , MonsterAI (PAUSED),

Arkshine is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 08-08-2015 , 08:32   Re: Objective Reset + Timer Control [V 0.1]
Reply With Quote #3

Quote:
Originally Posted by Arkshine View Post
Looks like you did not tested this under linux, the typo in get/set_pdata_bool stocks about linux extra offset is still there.
I've tested in linux, it seems that for the grenade offset the diff is 5 and not 4. Or you may be talking about another typo.
__________________

Last edited by HamletEagle; 08-08-2015 at 08:34.
HamletEagle is offline
Old 08-08-2015, 09:06
Arkshine
This message has been deleted by Arkshine. Reason: nvm I guess
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 08-08-2015 , 09:12   Re: Objective Reset + Timer Control [V 0.1]
Reply With Quote #4

I was not talking about that, but was looking at the wrong stock anyway. Since stock uses _int native, extra linux is fine. Passing a char-based offset, while you pass int-based extra offset is quite confusing.
Nevermind then. Sigh, I wish next AMXX version would be already released so we would not need to rely on such silly stock.
__________________
Working on : CS Weapon Mod (72%) , MonsterAI (PAUSED),


Last edited by Arkshine; 08-08-2015 at 09:13.
Arkshine is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 08-08-2015 , 09:35   Re: Objective Reset + Timer Control [V 0.1]
Reply With Quote #5

Alright then. Yes, it would be good, but now the other alternative is to use flags. Any others comments/improvements/suggestions ?
__________________

Last edited by HamletEagle; 08-08-2015 at 10:55.
HamletEagle is offline
EFFx
Veteran Member
Join Date: Feb 2016
Location: [<o>]
Old 01-11-2018 , 22:18   Re: Objective Reset + Timer Control [V 0.1]
Reply With Quote #6

I did a little work using one feature (SetRoundTime):

PHP Code:
#include <amxmodx>
#include <objective_reset>

#define PLUGIN        "Pause Round"
#define VERSION     "1.0"
#define AUTHOR         "author"

#define TASK_PAUSE    2301031

new bool:g_bPausedbool:g_bPauseAskedg_bIsFreezeTime
new g_iPauses[2], g_iLastPause[2], g_iTeamg_iCountDown
new pCvarPauseTimepCvarMaxPausespCvarPauseDelay

public plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
pCvarMaxPauses register_cvar("pause_maxpauses_perteam""3")
    
pCvarPauseTime register_cvar("pause_pausetime""60")
    
pCvarPauseDelay register_cvar("pause_pausedelay""120")
    
    
register_logevent("RoundStart"2"1=Round_Start")  
    
register_event("HLTV""NewRound""a""1=0""2=0")  
    
    
register_clcmd("say /pause""cmdPause")
    
register_clcmd("say /unpause""cmdUnpause")
}

public 
RoundStart()
{
    
g_bIsFreezeTime false
}

public 
NewRound()
{
    
g_bIsFreezeTime true
    
if(g_bPauseAsked)
    {
        
pauseGame()
    }
}

public 
cmdPause(id)
{
    new 
iUserTeam get_user_team(id), iTeam = (iUserTeam 1)
    if(
iUserTeam >= 3)
    {
        
client_print(idprint_chat"[AMXX]: You cannot use this command while spectating.")
        return 
PLUGIN_HANDLED
    
}

    if(
g_bPaused)
    {
        
client_print(idprint_chat"[AMXX]: The game is already paused.")
        return 
PLUGIN_HANDLED
    
}
    
    if(
g_bPauseAsked)
    {
        
client_print(idprint_chat"[AMXX]: The %s already asked the pause."g_iTeam "Counter-Terrorists" "Terrorists")
        return 
PLUGIN_HANDLED
    
}
    
    if(
g_iPauses[(g_iTeam iTeam)] == get_pcvar_num(pCvarMaxPauses))
    {
        
client_print(idprint_chat"[AMXX]: Your team cannot pause anymore.")
        return 
PLUGIN_HANDLED
    
}

    new 
iSystime get_systime()
    if(
iSystime g_iLastPause[iTeam])
    {
        new 
iMath = (g_iLastPause[iTeam] - iSystime)
        if(
iMath get_pcvar_num(pCvarPauseDelay))
        {
            
client_print(idprint_chat"[AMXX]: Your team must wait %d second%s to ask a pause again."iMath, (iMath 1) ? "s" "")
            return 
PLUGIN_HANDLED
        
}
    }
    
    new 
szName[32]
    
get_user_name(idszNamecharsmax(szName))
    
client_print(idprint_chat"[AMXX]: Player %s wants to pause the game."szName)

    
g_bPauseAsked true
    
if(g_bIsFreezeTime)
    {
        
pauseGame()
    }
    else
    {
        
client_print(idprint_chat"[AMXX]: The game will be paused during the freezetime.")
    }
    
    return 
PLUGIN_HANDLED
}

public 
cmdUnpause(id)
{
    if(
get_user_team(id) > 2)
    {
        
client_print(idprint_chat"[AMXX]: You cannot use this command while spectating.")
        return 
PLUGIN_HANDLED
    
}

    if(!
g_bPaused)
    {
        
client_print(idprint_chat"[AMXX]: The game is not paused.")
        return 
PLUGIN_HANDLED
    
}
    
    new 
szName[32]
    
get_user_name(idszNamecharsmax(szName))
    
client_print(idprint_chat"[AMXX]: Player %s unpaused the game."szName)

    
unpauseGame()
    return 
PLUGIN_HANDLED
}

pauseGame()
{
    new 
iCvarPauseTime get_pcvar_num(pCvarPauseTime), iCvarMaxPauses get_pcvar_num(pCvarMaxPauses)
    
    
g_bPaused true
    g_bPauseAsked 
false
    g_iPauses
[g_iTeam]++
    
g_iCountDown iCvarPauseTime

    
new szTeam[19];szTeam g_iTeam "Counter-Terrorists" "Terrorists"
    
    
client_print(0print_chat"[AMXX]: Game paused by %s."szTeam)
    
    new 
szMessage[32]
    if(
g_iPauses[g_iTeam] < iCvarMaxPauses)
    {
        
formatex(szMessagecharsmax(szMessage), "They still have %d pauses left.", (iCvarMaxPauses g_iPauses[g_iTeam]))
    }
    else
    {
        
formatex(szMessagecharsmax(szMessage), "They have not pauses to ask anymore.")
    }
    
client_print(0print_chat"[AMXX]: %s"szMessage)
    
client_print(0print_chat"[AMXX]: The %s have %d second%s to unpause the game."szTeamiCvarPauseTime, (iCvarPauseTime 1) ? "s" "")
    
    
set_task(1.0"setPause"TASK_PAUSE, .flags "b")
}

unpauseGame()
{
    
g_iLastPause[g_iTeam] = get_systime() + get_pcvar_num(pCvarPauseDelay)
    
g_bPaused false
    g_iTeam 
0
    g_iCountDown 
0
    remove_task
(TASK_PAUSE)
}

public 
setPause()
{
    
set_hudmessage(255255255, -1.00.301.01.0)
    
show_hudmessage(0"GAME PAUSED")
    
    
SetRoundTime(11)
    
    new 
szTeam[19];szTeam g_iTeam "Counter-Terrorists" "Terrorists"
    
if(g_iCountDown == (get_pcvar_num(pCvarPauseTime) / 2))
    {
        
client_print(0print_chat"[AMXX]: The %s team have %d seconds left to unpause."szTeam, (get_pcvar_num(pCvarPauseTime) / 2))
    }
    else if(
g_iCountDown == 0)
    {
        
unpauseGame()
        
client_print(0print_chat"[AMXX]: The %s team pause time has ended."szTeam)
    }
    
    
g_iCountDown--

Basically, it's a Pause command, usefull for Pug.
__________________
PUBG MOD

177.54.156.194:27014

Last edited by EFFx; 01-12-2018 at 07:39.
EFFx is offline
Send a message via Skype™ to EFFx
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 01-12-2018 , 02:18   Re: Objective Reset + Timer Control [V 0.1]
Reply With Quote #7

If you included objective_reset you should use SetRoundTime native instead of server_cmd.
__________________

Last edited by HamletEagle; 01-12-2018 at 02:18.
HamletEagle is offline
EFFx
Veteran Member
Join Date: Feb 2016
Location: [<o>]
Old 01-12-2018 , 05:18   Re: Objective Reset + Timer Control [V 0.1]
Reply With Quote #8

I didn't notice that, damn it. I changed the format.

Edit: Added some updates.
__________________
PUBG MOD

177.54.156.194:27014

Last edited by EFFx; 01-12-2018 at 07:39.
EFFx is offline
Send a message via Skype™ to EFFx
Reply


Thread Tools
Display Modes

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 23:31.


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