Raised This Month: $12 Target: $400
 3% 

Objective Reset + Timer Control [V 0.1]


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
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 on one of my friend requests in the last few weeks, and it turned in a useful and nice plugin, so I decided to post it here. Basically, this plugin has two interconnected parts.
  • Reset the objective:
    • The idea is that you can reset the current round progress as it was at the beginning of the round. For mods like furien/fun/classic, it is a nice addon.
    • All default objectives are supported(and it 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 sent to their old position, no matter if they were rescued/killed/somewhere on the map. When resetting, the number of rescued hostages is set to 0.
      • Vip: when the cmd is used another VIP is picked and he is sent to the 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 gets all the attributes of a VIP.
      • Escape: I'm not quite sure about this one since I never played es_ maps before, if you want the plugin to do more in this scenario let me know. For now, what it does 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 an objective, but the command to alter the timer(add/remove seconds) is not.
  • Control the round timer: the idea is to make changes to the round timer that will take effect immediately, with freeze time support. If someone uses the command in freeze time, then freeze will be altered, or the round time will.

Requirements top

You need the following 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 these reset, the names are intuitive. If you specify detect, then the objective will be auto-detected. In the 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 the 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 game functions to do what it does and these functions may be hooked by other plugins. If this cvar is set to 1, every plugin that hooks one of these functions will know about this call and execute its one code, if not it will be ignored. My reasoning behind this cvar was that you may run some incompatible plugins that supersede 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 its purpose or if it is not needed. A reliable message is sent to the 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 sent if something went wrong(but you will get some gameplay problems as the round timer not updating 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, 463 views)
File Type: inc objective_reset.inc (1.7 KB, 505 views)
File Type: sma Get Plugin or Get Source (ObjectiveReset.sma - 1331 views - 23.3 KB)
__________________

Last edited by HamletEagle; 08-23-2021 at 11:32.
HamletEagle is offline
 


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 14:06.


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