Skip to content

Instantly share code, notes, and snippets.

@shavitush
Last active August 22, 2016 23:39
Show Gist options
  • Save shavitush/0e87ce51de2bde502af18746274d1883 to your computer and use it in GitHub Desktop.
Save shavitush/0e87ce51de2bde502af18746274d1883 to your computer and use it in GitHub Desktop.
jailbreak givelr
#include <sourcemod>
#include <sdktools>
#include <cstrike>
#pragma semicolon 1
#pragma newdecls required
char gS_Prefix[32];
bool gB_GiveLR = false;
public Plugin myinfo =
{
name = "Jailbreak GiveLR",
author = "shavitush",
description = "Let someone else have your lastrequest.",
version = "1.0",
url = "https://github.com/shavitush"
};
public void OnPluginStart()
{
// strings
FormatEx(gS_Prefix, 32, "%s\x04[Jailbreak]\x01", (GetEngineVersion() == Engine_CSGO)? " ":"");
LoadTranslations("common.phrases");
// command
RegConsoleCmd("sm_givelr", Command_GiveLR, "Let someone else have your lastrequest. Usage: sm_givelr <target>");
// hook
HookEvent("round_start", Round_Start);
}
public Action Command_GiveLR(int client, int args)
{
if(!IsValidClient(client))
{
return Plugin_Handled;
}
if(!IsPlayerAlive(client))
{
ReplyToCommand(client, "%s You have to be alive in order to use this command.", gS_Prefix);
return Plugin_Handled;
}
int count = 0;
for(int i = 1; i <= MaxClients; i++)
{
if(!IsValidClient(i, true))
{
continue;
}
if(GetClientTeam(i) == CS_TEAM_T && ++count > 1)
{
break;
}
}
if(count != 1)
{
ReplyToCommand(client, "%s Only 1 terrorist has to be alive, and it has to be you.", gS_Prefix);
return Plugin_Handled;
}
if(gB_GiveLR)
{
ReplyToCommand(client, "%s This command cannot be used more than once per round, sorry.", gS_Prefix);
return Plugin_Handled;
}
if(args == 0)
{
ReplyToCommand(client, "%s Usage: sm_givelr <target>", gS_Prefix);
return Plugin_Handled;
}
char[] sArgs = new char[MAX_TARGET_LENGTH];
GetCmdArgString(sArgs, MAX_TARGET_LENGTH);
int target = FindTarget(client, sArgs, true, false);
if(target == -1)
{
return Plugin_Handled;
}
PrintToChatAll("%s \x03%N\x01 gave his LR to \x03%N\x01!", gS_Prefix, client, target);
CS_RespawnPlayer(target);
float vOrigin[3];
GetClientAbsOrigin(client, vOrigin);
TeleportEntity(target, vOrigin, NULL_VECTOR, NULL_VECTOR);
ForcePlayerSuicide(client);
gB_GiveLR = true;
return Plugin_Handled;
}
public void Round_Start(Event event, const char[] name, bool dontBroadcast)
{
gB_GiveLR = false;
}
stock bool IsValidClient(int client, bool bAlive = false)
{
return (client >= 1 && client <= MaxClients && IsClientConnected(client) && IsClientInGame(client) && (!bAlive || IsPlayerAlive(client)));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment