Skip to content

Commit

Permalink
Added mayhem manager
Browse files Browse the repository at this point in the history
also updated airblastreload to 1.7 syntax
  • Loading branch information
Rokerekor committed Dec 27, 2016
1 parent b870a4a commit 9f655f5
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 10 deletions.
20 changes: 10 additions & 10 deletions enhancements/10x/airblastreload.sp
Expand Up @@ -6,11 +6,11 @@
#pragma semicolon 1

//-----------------------------------------------------------------------------
public Plugin:myinfo = {
public Plugin myinfo = {
name = "Airblast Ammo Refund",
author = "WhiteThunder",
description = "Refunds ammo after successful airblast with stock flamethrower",
version = "1.0.1",
version = "1.0.2",
url = "www.reflex-gamers.com"
};

Expand All @@ -26,22 +26,22 @@ public OnPluginStart() {
}

//-----------------------------------------------------------------------------
public Action:Event_AirBlast( Handle:event, const String:name[], bool:dontBroadcast ) {
public Action Event_AirBlast( Handle event, const char name[], bool dontBroadcast ) {

new client = GetClientOfUserId( GetEventInt( event, "userid" ) );
new weapon = GetPlayerWeaponSlot( client, TFWeaponSlot_Primary );
int client = GetClientOfUserId( GetEventInt( event, "userid" ) );
int weapon = GetPlayerWeaponSlot( client, TFWeaponSlot_Primary );

new index = ( IsValidEntity(weapon) ? GetEntProp( weapon, Prop_Send, "m_iItemDefinitionIndex" ) : -1 );
int index = ( IsValidEntity(weapon) ? GetEntProp( weapon, Prop_Send, "m_iItemDefinitionIndex" ) : -1 );

if( index != WEAPON_INDEX ) {
return Plugin_Continue;
}

new iOffset = GetEntProp( weapon, Prop_Send, "m_iPrimaryAmmoType", 1 ) * 4;
new iAmmoTable = FindSendPropInfo( "CTFPlayer", "m_iAmmo" );
new currentAmmo = GetEntData( client, iAmmoTable + iOffset, 4 );
int iOffset = GetEntProp( weapon, Prop_Send, "m_iPrimaryAmmoType", 1 ) * 4;
int iAmmoTable = FindSendPropInfo( "CTFPlayer", "m_iAmmo" );
int currentAmmo = GetEntData( client, iAmmoTable + iOffset, 4 );

new newAmmo = currentAmmo > AMMO_MAX ? AMMO_MAX : currentAmmo;
int newAmmo = currentAmmo > AMMO_MAX ? AMMO_MAX : currentAmmo;
SetEntData( client, iAmmoTable + iOffset, newAmmo + AMMO_COST * REFUND_MULTIPLIER, 4, true );

int maxHealth = GetEntProp(client, Prop_Data, "m_iMaxHealth");
Expand Down
55 changes: 55 additions & 0 deletions enhancements/10x/mayhem_manager.sp
@@ -0,0 +1,55 @@
#include <sourcemod>
#include <sdktools>

#pragma semicolon 1
#pragma newdecls required

public Plugin myinfo =
{
name = "Mayhem Manager",
author = "Roker",
description = "Manages the 10x plugins.",
version = "1.0.0",
url = "www.reflex-gamers.com"
};

Handle sm_mayhem_enabled;

public void OnPluginStart(){
sm_mayhem_enabled = CreateConVar( "sm_mayhem_enabled", "1", "If mayhem plugins are enabled.", FCVAR_PLUGIN, true, 0.0, true, 1.0 );
HookConVarChange( sm_mayhem_enabled, OnConVarChanged );
SetPluginsEnabled();
}

public void OnPluginEnd(){
SetPluginsEnabled();
}

//-------------------------------------------------------------------------------------------------
public void OnConVarChanged( Handle cvar, const char[] oldval, const char[] newval ) {
PrintToChatAll("%s" , newval);
SetPluginsEnabled();
}

void SetPluginsEnabled(){
bool enabled = GetConVarBool(sm_mayhem_enabled);

char path[PLATFORM_MAX_PATH], filename[PLATFORM_MAX_PATH];
FileType filetype;
BuildPath(Path_SM, path, PLATFORM_MAX_PATH, "plugins/mayhem");

Handle directory = OpenDirectory(path);

while(ReadDirEntry(directory, filename, PLATFORM_MAX_PATH, filetype)){
if(filetype==FileType_File && StrContains(filename, ".mayhem", false)!=-1){
char cmd[6];
if(enabled){
cmd = "load";
}else{
cmd = "unload";
}

ServerCommand("sm plugins %s mayhem/%s", cmd, filename);
}
}
}

0 comments on commit 9f655f5

Please sign in to comment.