Skip to content

Instantly share code, notes, and snippets.

@hakusaro
Created May 19, 2013 02:12
Show Gist options
  • Save hakusaro/5606407 to your computer and use it in GitHub Desktop.
Save hakusaro/5606407 to your computer and use it in GitHub Desktop.
Not actually C++, it's SourcePawn.
//http://code.google.com/p/ihackedgmod/
//http://creativecommons.org/licenses/by-sa/3.0/
#include <sourcemod>
#include <sdktools>
#include <colors>
public Plugin:myinfo =
{
name = "Build Mode",
author = "nicatronTg",
description = "Plugin by nicatronTg(Shank)",
version = "0.0",
url = "http://twitter.com/nicatronTg"
}
public OnPluginStart()
{
CreateTimer(15.0, LoadStuff)
HookEvent("player_hurt", event_PlayerHurt, EventHookMode_Pre);
RegConsoleCmd("say", ConsoleParse)
}
public Action:event_PlayerHurt(Handle:event, const String:name[], bool:dontBroadcast) {
new client = GetClientOfUserId(GetEventInt(event, "attacker"));
if (
client && // Not world/self
GetEntityFlags(client) & FL_GODMODE // attacker is in god-mode
) {
client = GetClientOfUserId(GetEventInt(event, "userid"));
SetEntProp(client, Prop_Send, "m_iHealth", GetClientHealth(client) + RoundToCeil(GetEventFloat(event, "damage"))); // Restore health
SetEventFloat(event, "damage", 0.0); // Remove damage for other plugins
}
return Plugin_Continue;
}
public Action:LoadStuff(Handle:timer)
{
/*Insert all pre-run code here.*/
AutoExecConfig(true, "build_config")
CPrintToChatAll("{green}[Build Mode] {default}Protected by Build Mode.")
CPrintToChatAll("{green}[Build Mode] {default}Created by nicatronTg")
CPrintToChatAll("{green}[Build Mode] {default}Released under Creative Commons 3.0 Share Alike Unported")
CPrintToChatAll("{green}[Build Mode] {default}http://code.google.com/p/ihackedgmod/")
return Plugin_Handled;
//Removing this portion violates the copyright placed upon this code.
//Making this section un-reachable in any means will also violate the CC 3.0 BY-SA.
//Any attempt to remove it will result in a case in the state of Colorado Arapahoe County Court sytems
//I ain't fucking with you, you can read.
}
public Action:ConsoleParse(client, args)
{
/*Snippet from http://wiki.alliedmods.net/Commands_%28SourceMod_Scripting%29*/
new String:text[192];
GetCmdArgString(text, sizeof(text));
new startidx = 0;
if (text[0] == '"')
{
startidx = 1
/* Strip the ending quote, if there is one */
new len = strlen(text);
if (text[len-1] == '"')
{
text[len-1] = '\0'
}
} //Why re-create the wheel? Just steal from a pre-built snippet
if(StrEqual(text[startidx], "!build"))
{
CPrintToChatAll("{green}[Build]{default} %t has entered build mode. Killing them via alternate means will result in a permanent ban.", client)
CPrintToChat(client, "{green}[Build]{default} Change your name so that it begins with (NoKill)")
GodMe(client, true)
return Plugin_Continue;
}
else if(StrEqual(text[startidx], "!dm"))
{
CPrintToChatAll("{green}[Build]{default} %t Doesn't like people, so he's coming after you.", client)
CPrintToChat(client, "{green}[Build]{default} Change your name back from (NoKill). You aren't invulnerable.")
GodMe(client, false)
return Plugin_Continue;
}
return Plugin_Continue;
}
bool:GodMe(const any:client, const bool:mode) {
new fFlags = GetEntProp(client, Prop_Data, "m_fFlags");
if (mode) { // Wants nokill mode
if (fFlags & FL_GODMODE) { // Already god-moded
return false;
} else { // Not a god.
fFlags += FL_GODMODE; // Add god-flag
}
} else { // Wants to be killable.
if (fFlags & FL_GODMODE) { // Currently god-moded.
fFlags -= FL_GODMODE; // Add god-flag
} else { // Already killable
return false;
}
}
SetEntProp(client, Prop_Data, "m_fFlags", fFlags); // Set new flags
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment