Same plugin, but with chat trigger, flags checking, and colored chat prints:
Requirements: Multi Colors (include).
PHP Code:
#include <sourcemod>
#include <sdktools>
#include <multicolors>
public Plugin:myinfo =
{
name = "[Deathrun] Decoy Teleporter",
author = "Purixi",
description = "",
version = "1.0",
url = ""
}
new g_AllowedDecoys[33];
public OnPluginStart()
{
HookEvent("decoy_firing", OnDecoyFiring);
HookEvent("round_start", OnRoundStart);
RegConsoleCmd("decoy", OnCommandExecuted);
}
public OnClientPutInServer(client)
{
if(!IsFakeClient(client)) g_AllowedDecoys[client] = 1;
}
public Action:OnCommandExecuted(client, args)
{
new flags = GetUserFlagBits(client);
if(flags & ADMFLAG_GENERIC || flags & ADMFLAG_ROOT)
{
if(g_AllowedDecoys[client] > 0)
{
g_AllowedDecoys[client]--;
GivePlayerItem(client, "weapon_decoy");
CPrintToChat(client, "{green}[Decoy Teleporter] {orange}You've been granted a {green}Decoy Teleporter{orange}. Use it with brain.");
}
else
{
CPrintToChat(client, "{green}[Decoy Teleporter] {orange}You have already used all available {green}Decoy Teleporters{orange}.");
}
}
else
{
CPrintToChat(client, "{green}[Decoy Teleporter] {orange}You don't have permissions to access following command.");
}
}
public OnRoundStart(Handle:event, const String:name[], bool:dontBroadcast)
{
new userid = GetEventInt(event, "userid");
new client = GetClientOfUserId(userid);
g_AllowedDecoys[client] = 1;
}
public OnDecoyFiring(Handle:event, const String:name[], bool:dontBroadcast)
{
new userid = GetEventInt(event, "userid");
new client = GetClientOfUserId(userid);
new flags = GetUserFlagBits(client);
if(flags & ADMFLAG_GENERIC || flags & ADMFLAG_ROOT)
{
new Float:f_Pos[3];
new entityid = GetEventInt(event, "entityid");
f_Pos[0] = GetEventFloat(event, "x");
f_Pos[1] = GetEventFloat(event, "y");
f_Pos[2] = GetEventFloat(event, "z");
TeleportEntity(client, f_Pos, NULL_VECTOR, NULL_VECTOR);
RemoveEdict(entityid);
}
}