Skip to content

Commit

Permalink
updated API
Browse files Browse the repository at this point in the history
- separate includes for plugins
- new forward dr_chosen_new_terrorist
- changed dr_duel_canceled
  • Loading branch information
Mistrick committed Oct 1, 2016
1 parent 003ff57 commit 3b1d507
Show file tree
Hide file tree
Showing 6 changed files with 177 additions and 109 deletions.
19 changes: 14 additions & 5 deletions deathrun_core.sma
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#endif

#define PLUGIN "Deathrun: Core"
#define VERSION "1.0"
#define VERSION "1.1.0"
#define AUTHOR "Mistrick"

#pragma semicolon 1
Expand All @@ -33,9 +33,14 @@ enum _:Cvars
RESTART
};

enum Forwards
{
FW_NEW_TERRORIST
};

new const PREFIX[] = "^4[DRM]";

new g_eCvars[Cvars], g_bWarmUp = true;
new g_eCvars[Cvars], g_iForwards[Forwards], g_iReturn, g_bWarmUp = true;
new g_iForwardSpawn, HamHook:g_iHamPreThink, Trie:g_tRemoveEntities;
new g_msgShowMenu, g_msgVGUIMenu, g_msgAmmoPickup, g_msgWeapPickup;
new g_iOldAmmoPickupBlock, g_iOldWeapPickupBlock, g_iTerrorist, g_iNextTerrorist, g_iMaxPlayers;
Expand Down Expand Up @@ -70,7 +75,7 @@ public plugin_init()

register_touch("func_door", "weaponbox", "Engine_TouchFuncDoor");

g_iHamPreThink = RegisterHam(Ham_Player_PreThink, "player", "Ham_PlayerPreThink_Post", true);
g_iForwards[FW_NEW_TERRORIST] = CreateMultiForward("dr_chosen_new_terrorist", ET_IGNORE, FP_CELL);

g_msgVGUIMenu = get_user_msgid("VGUIMenu");
g_msgShowMenu = get_user_msgid("ShowMenu");
Expand All @@ -80,7 +85,7 @@ public plugin_init()
register_message(g_msgVGUIMenu, "Message_Menu");
register_message(g_msgShowMenu, "Message_Menu");

DisableHamForward(g_iHamPreThink);
DisableHamForward(g_iHamPreThink = RegisterHam(Ham_Player_PreThink, "player", "Ham_PlayerPreThink_Post", true));
unregister_forward(FM_Spawn, g_iForwardSpawn, 0);
TrieDestroy(g_tRemoveEntities);

Expand Down Expand Up @@ -129,6 +134,7 @@ public plugin_cfg()
}
public plugin_natives()
{
register_library("deathrun_core");
register_native("dr_get_terrorist", "native_get_terrorist", 1);
register_native("dr_set_next_terrorist", "native_set_next_terrorist", 1);
register_native("dr_get_next_terrorist", "native_get_next_terrorist", 1);
Expand Down Expand Up @@ -166,6 +172,8 @@ public client_disconnect(id)
ExecuteHamB(Ham_CS_RoundRespawn, g_iTerrorist);
engfunc(EngFunc_SetOrigin, g_iTerrorist, fOrigin);

ExecuteForward(g_iForwards[FW_NEW_TERRORIST], g_iReturn, g_iTerrorist);

new szName[32]; get_user_name(g_iTerrorist, szName, charsmax(szName));
new szNameLeaver[32]; get_user_name(id, szNameLeaver, charsmax(szNameLeaver));
client_print_color(0, print_team_red, "%s %L", PREFIX, LANG_PLAYER, "DRC_TERRORIST_LEFT", szNameLeaver, szName);
Expand Down Expand Up @@ -239,7 +247,8 @@ TerroristCheck()
{
new players[32], pnum; get_players(players, pnum, "ae", "TERRORIST");
g_iTerrorist = pnum ? players[0] : 0;
}
}
ExecuteForward(g_iForwards[FW_NEW_TERRORIST], g_iReturn, g_iTerrorist);
}
//******** Messages Credits: PRoSToTeM@ ********//
public Message_Menu(const msg, const nDest, const nClient)
Expand Down
24 changes: 18 additions & 6 deletions deathrun_mode_duel.sma
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#endif

#define PLUGIN "Deathrun Mode: Duel"
#define VERSION "1.0"
#define VERSION "1.0.1"
#define AUTHOR "Mistrick"

#pragma semicolon 1
Expand All @@ -25,6 +25,14 @@
#define MAX_DISTANCE 1500
#define MIN_DISTANCE 300

enum CancelType
{
CType_TimeOver,
CType_PlayerDisconneced,
CType_PlayerDied,
CType_ModeChanged
};

enum (+=100)
{
TASK_TURNCHANGER = 100,
Expand Down Expand Up @@ -127,7 +135,7 @@ public plugin_init()
g_iForwards[DUEL_PRESTART] = CreateMultiForward("dr_duel_prestart", ET_IGNORE, FP_CELL, FP_CELL);
g_iForwards[DUEL_START] = CreateMultiForward("dr_duel_start", ET_IGNORE, FP_CELL, FP_CELL);
g_iForwards[DUEL_FINISH] = CreateMultiForward("dr_duel_finish", ET_IGNORE, FP_CELL, FP_CELL);
g_iForwards[DUEL_CANCELED] = CreateMultiForward("dr_duel_canceled", ET_IGNORE);
g_iForwards[DUEL_CANCELED] = CreateMultiForward("dr_duel_canceled", ET_IGNORE, FP_CELL);

g_iModeDuel = dr_register_mode
(
Expand Down Expand Up @@ -161,6 +169,10 @@ public plugin_cfg()
register_dictionary("deathrun_mode_duel.txt");
LoadSpawns();
}
public plugin_natives()
{
register_library("deathrun_duel");
}
LoadSpawns()
{
new szConfigDir[128]; get_localinfo("amxx_configsdir", szConfigDir, charsmax(szConfigDir));
Expand Down Expand Up @@ -258,7 +270,7 @@ public client_disconnect(id)
if((g_bDuelStarted) && (id == g_iDuelPlayers[DUELIST_CT] || id == g_iDuelPlayers[DUELIST_T]))
{
ResetDuel();
ExecuteForward(g_iForwards[DUEL_CANCELED], g_iReturn);
ExecuteForward(g_iForwards[DUEL_CANCELED], g_iReturn, CType_PlayerDisconneced);
}
}
public Command_Drop(id)
Expand Down Expand Up @@ -502,7 +514,7 @@ public Task_DuelTimer()
ExecuteHam(Ham_Killed, g_iDuelPlayers[DUELIST_CT], g_iDuelPlayers[DUELIST_CT], 0);
ExecuteHam(Ham_Killed, g_iDuelPlayers[DUELIST_T], g_iDuelPlayers[DUELIST_T], 0);

ExecuteForward(g_iForwards[DUEL_CANCELED], g_iReturn);
ExecuteForward(g_iForwards[DUEL_CANCELED], g_iReturn, CType_TimeOver);
ResetDuel();

client_print_color(0, print_team_default, "%s^1 %L", PREFIX, LANG_PLAYER, "DRD_TIME_OVER");
Expand Down Expand Up @@ -624,7 +636,7 @@ public Ham_PlayerKilled_Post(victim, killer)
}
else
{
ExecuteForward(g_iForwards[DUEL_CANCELED], g_iReturn);
ExecuteForward(g_iForwards[DUEL_CANCELED], g_iReturn, CType_PlayerDied);
}
ResetDuel();
}
Expand Down Expand Up @@ -675,7 +687,7 @@ public dr_selected_mode(id, mode)
if(g_bDuelStarted && mode != g_iModeDuel)
{
ResetDuel();
ExecuteForward(g_iForwards[DUEL_CANCELED], g_iReturn);
ExecuteForward(g_iForwards[DUEL_CANCELED], g_iReturn, CType_ModeChanged);
}
}
ResetDuel()
Expand Down
5 changes: 4 additions & 1 deletion deathrun_shop.sma
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
#include <amxmodx>
#include <cstrike>

#if AMXX_VERSION_NUM < 183
#include <colorchat>
#endif

#define PLUGIN "Deathrun: Shop"
#define VERSION "0.1"
#define VERSION "0.1.1"
#define AUTHOR "Mistrick"

#pragma semicolon 1
Expand Down
41 changes: 41 additions & 0 deletions include/deathrun_core.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#if defined _deathrun_core_included
#endinput
#endif
#define _deathrun_core_included

#if AMXX_VERSION_NUM >= 175
#pragma reqlib deathrun_core
#if !defined AMXMODX_NOAUTOLOAD
#pragma loadlib deathrun_core
#endif
#else
#pragma library deathrun_core
#endif

/**
* Forward which called when chosen new terrorist(new round or disconnect).
*
* @param id Player index.
*/
forward dr_chosen_new_terrorist(id);

/**
* Get player index current terrorist.
*
* @return Player index.
*/
native dr_get_terrorist();

/**
* Set player who became terrorist in new round.
*
* @param id Next terrorist index.
*/
native dr_set_next_terrorist(id);

/**
* Get player who became terrorist in new round.
*
* @return Player index.
*/
native dr_get_next_terrorist();
52 changes: 52 additions & 0 deletions include/deathrun_duel.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#if defined _deathrun_duel_included
#endinput
#endif
#define _deathrun_duel_included

#if AMXX_VERSION_NUM >= 175
#pragma reqlib deathrun_duel
#if !defined AMXMODX_NOAUTOLOAD
#pragma loadlib deathrun_duel
#endif
#else
#pragma library deathrun_duel
#endif

enum CancelType
{
CType_TimeOver,
CType_PlayerDisconneced,
CType_PlayerDied,
CType_ModeChanged
}

/**
* Forward which called before duel start, warm up time
*
* @param duelist_ct Player index.
* @param duelist_t Player index.
*/
forward dr_duel_prestart(duelist_ct, duelist_t);

/**
* Forward which called when duel started
*
* @param duelist_ct Player index.
* @param duelist_t Player index.
*/
forward dr_duel_start(duelist_ct, duelist_t);

/**
* Forward which called when duel overed
*
* @param winner Player index.
* @param looser Player index.
*/
forward dr_duel_finish(winner, looser);

/**
* Forward which called when duel canceled
*
* @param type Cancel type
*/
forward dr_duel_canceled(CancelType:type);
Loading

0 comments on commit 3b1d507

Please sign in to comment.