Files
sm-plugins/Couch/scripting/include/Couch.inc
T
2026-09-29 17:36:33 +01:00

188 lines
5.8 KiB
SourcePawn

#if defined _Couch_included
#endinput
#endif
#define _Couch_included
// How a player moved the couch, passed to Couch_OnCouchInteraction.
enum CouchMethod
{
CouchMethod_Bullet, // Gunfire; weapon is the gun, e.g. "ak47".
CouchMethod_Knife, // weapon is "knife".
CouchMethod_Grenade, // weapon is "hegrenade".
CouchMethod_Use, // +use; weapon is empty.
CouchMethod_Other // Any other damage credited to a player; weapon is the inflictor's classname.
};
// The core defines COUCH_CORE; it creates the forwards and natives itself.
#if !defined COUCH_CORE
/**
* Called after the couch has been created, for admin spawns and round-start respawns.
*
* @param couch Entity index of the new couch.
*/
forward void Couch_OnCouchSpawned(int couch);
/**
* Called once the couch entity is gone, for whatever reason. Couch_IsPlaced() tells whether
* it will come back at the next round start.
*/
forward void Couch_OnCouchRemoved();
/**
* Called for every hit the couch accepts from a player. Shotguns report once per pellet.
*
* @param couch Entity index of the couch.
* @param attacker Client index of the player who dealt the damage.
* @param damage Damage dealt by this hit.
*/
forward void Couch_OnCouchDamaged(int couch, int attacker, float damage);
/**
* Called for every hit or +use the couch accepts from a player, saying how it was moved. Hits
* fire alongside Couch_OnCouchDamaged, so shotguns report once per pellet.
*
* @param couch Entity index of the couch.
* @param client Client index of the player.
* @param method How the couch was moved.
* @param weapon Weapon without its "weapon_" prefix, see CouchMethod.
*/
forward void Couch_OnCouchInteraction(int couch, int client, CouchMethod method, const char[] weapon);
/**
* Called when a hit or +use from a blocked client is refused. Fires per pellet, so rate-limit anything you send.
*
* @param couch Entity index of the couch.
* @param client Client index of the blocked player.
*/
forward void Couch_OnClientBlocked(int couch, int client);
/**
* @return Entity index of the couch, or -1 if there is none.
*/
native int Couch_GetCouch();
/**
* Whether an admin has placed a couch this map. While true the couch respawns at the placed
* spot every round start.
*
* @return True if a placement is remembered.
*/
native bool Couch_IsPlaced();
/**
* Spawns the couch where the client is aiming, replacing any existing couch. The spot becomes
* the respawn point.
*
* @param client Client whose crosshair places the couch. Must be in game.
* @return Entity index of the couch, or -1 on failure.
*/
native int Couch_Spawn(int client);
/**
* Teleports the couch to where the client is aiming. The respawn point is left as it was.
*
* @param client Client whose crosshair places the couch. Must be in game.
* @return True on success, false if there is no couch.
*/
native bool Couch_Bring(int client);
/**
* Teleports the client onto the couch, or beside it when the top is blocked. The client keeps
* their view angles and arrives with no velocity.
*
* @param client Client to teleport. Must be in game.
* @return True on success, false if there is no couch.
*/
native bool Couch_Goto(int client);
/**
* Removes the couch and forgets its placement.
*
* @return True if a couch or a placement was removed.
*/
native bool Couch_Remove();
/**
* Whether the colour cycle and light are on. Mirrors sm_couch_effect.
*/
native bool Couch_IsEffectEnabled();
/**
* Switches the colour cycle and light on or off. Writes sm_couch_effect.
*/
native void Couch_SetEffectEnabled(bool enabled);
/**
* Whether only pistols and knives may move the couch. Mirrors sm_couch_pistol_only.
*/
native bool Couch_IsPistolOnly();
/**
* Restricts couch movement to pistols and knives, or lifts the restriction. Writes sm_couch_pistol_only.
*/
native void Couch_SetPistolOnly(bool enabled);
/**
* Whether players may +use the couch to pick it up. Mirrors sm_allow_couch_use.
*/
native bool Couch_IsUseAllowed();
/**
* Allows or forbids picking the couch up with +use; when forbidden it can only be shot. Writes sm_allow_couch_use.
*/
native void Couch_SetUseAllowed(bool allowed);
/**
* Blocks or unblocks a client from the couch: their hits are refused and their body can't push
* it. The flag is per slot and cleared on disconnect and map start; the caller owns persistence.
*
* @param client Client to block or unblock. Must be in game.
* @param blocked True to block, false to lift the block.
*/
native void Couch_SetClientBlocked(int client, bool blocked);
/**
* Whether the client is currently blocked from the couch.
*
* @param client Client index.
* @return True if blocked.
*/
native bool Couch_IsClientBlocked(int client);
public SharedPlugin __pl_Couch =
{
name = "Couch",
file = "Couch.smx",
#if defined REQUIRE_PLUGIN
required = 1
#else
required = 0
#endif
};
#if !defined REQUIRE_PLUGIN
public void __pl_Couch_SetNTVOptional()
{
MarkNativeAsOptional("Couch_GetCouch");
MarkNativeAsOptional("Couch_IsPlaced");
MarkNativeAsOptional("Couch_Spawn");
MarkNativeAsOptional("Couch_Bring");
MarkNativeAsOptional("Couch_Goto");
MarkNativeAsOptional("Couch_Remove");
MarkNativeAsOptional("Couch_IsEffectEnabled");
MarkNativeAsOptional("Couch_SetEffectEnabled");
MarkNativeAsOptional("Couch_IsPistolOnly");
MarkNativeAsOptional("Couch_SetPistolOnly");
MarkNativeAsOptional("Couch_IsUseAllowed");
MarkNativeAsOptional("Couch_SetUseAllowed");
MarkNativeAsOptional("Couch_SetClientBlocked");
MarkNativeAsOptional("Couch_IsClientBlocked");
}
#endif
#endif // COUCH_CORE