Re: SetTransmit
I've got this but all clients that aren't me get problems, like motd not working, not being able to a join a team and crashes:
PHP Code:
#include <tf2_stocks>
#include <sdkhooks>
new PlayerTeamFlag[MAXPLAYERS + 1];
new PlayerHasFlag[MAXPLAYERS+1] = false;
new TeamFlagOwner[2049];
public OnPluginStart()
{
RegConsoleCmd("sm_teamoutline", Command_TeamOutline);
HookEvent("player_death", Event_Death, EventHookMode_Pre);
HookEvent("player_spawn", Event_PlayerSpawn);
HookEvent("player_changeclass", Event_ChangeClass);
}
public OnClientPutInServer(client)
{
PlayerHasFlag[client] = false;
}
public OnMapStart()
{
for (new TFClassType:i = TFClass_Scout; i <= TFClass_Engineer; i++)
{
switch (i)
{
case TFClass_Scout: PrecacheModel("models/player/scout.mdl", true);
case TFClass_Soldier: PrecacheModel("models/player/soldier.mdl", true);
case TFClass_Pyro: PrecacheModel("models/player/pyro.mdl", true);
case TFClass_DemoMan: PrecacheModel("models/player/demo.mdl", true);
case TFClass_Heavy: PrecacheModel("models/player/heavy.mdl", true);
case TFClass_Engineer: PrecacheModel("models/player/engineer.mdl", true);
case TFClass_Medic: PrecacheModel("models/player/medic.mdl", true);
case TFClass_Sniper: PrecacheModel("models/player/sniper.mdl", true);
case TFClass_Spy: PrecacheModel("models/player/spy.mdl", true);
}
}
}
public OnPluginEnd()
{
for (new i = 1; i <= MaxClients; i++)
{
if (PlayerTeamFlag[i])
{
AcceptEntityInput(PlayerTeamFlag[i], "Kill");
}
}
}
public Action:Command_TeamOutline(client, args)
{
if (!args)
{
new String:arg0[35];
GetCmdArg(0, arg0, sizeof(arg0));
ReplyToCommand(client, "[SM] Usage: %s <target> [1/0] - Sets team-coloured outline on player(s).", arg0);
return Plugin_Handled;
}
new String:arg1[MAX_TARGET_LENGTH], bool:alwaysOff, bool:alwaysOn;
GetCmdArg(1, arg1, sizeof(arg1));
if (args > 1)
{
new String:arg2[2];
GetCmdArg(2, arg2, sizeof(arg2));
if (StringToInt(arg2)) alwaysOn = true;
else alwaysOff = true;
}
new String:target_name[MAX_TARGET_LENGTH], target_list[MAXPLAYERS], target_count, bool:tn_is_ml;
if ((target_count = ProcessTargetString(arg1, client, target_list, MAXPLAYERS, COMMAND_FILTER_ALIVE, target_name, sizeof(target_name), tn_is_ml)) <= 0)
{
ReplyToTargetError(client, target_count);
return Plugin_Handled;
}
for (new i = 0; i < target_count; i++)
{
new target = target_list[i], bool:giveOutline;
if (alwaysOn) giveOutline = true;
else if (alwaysOff)
{
giveOutline = false;
PlayerHasFlag[target] = false;
}
else if (PlayerTeamFlag[target]) giveOutline = false;
else giveOutline = true;
if (PlayerTeamFlag[target]) AcceptEntityInput(PlayerTeamFlag[target], "Kill");
if (giveOutline)
{
TeamOutlines(target);
}
}
if (alwaysOff) ShowActivity2(client, "[SM] ", "Disabled team-coloured outline on %s.", target_name);
else if (alwaysOn) ShowActivity2(client, "[SM] ", "Enabled team-coloured outline on %s.", target_name);
else ShowActivity2(client, "[SM] ", "Toggled team-coloured outline on %s.", target_name);
return Plugin_Handled;
}
TeamOutlines(target)
{
new Ent = CreateEntityByName("item_teamflag");
new Float:Pos[3];
GetEntPropVector(target, Prop_Send, "m_vecOrigin", Pos);
Pos[2] -= 2500.0;
TeleportEntity(Ent, Pos, NULL_VECTOR, NULL_VECTOR);
DispatchSpawn(Ent);
switch (TF2_GetPlayerClass(target))
{
case TFClass_Scout: SetEntityModel(Ent, "models/player/scout.mdl");
case TFClass_Soldier: SetEntityModel(Ent, "models/player/soldier.mdl");
case TFClass_Pyro: SetEntityModel(Ent, "models/player/pyro.mdl");
case TFClass_DemoMan: SetEntityModel(Ent, "models/player/demo.mdl");
case TFClass_Heavy: SetEntityModel(Ent, "models/player/heavy.mdl");
case TFClass_Engineer: SetEntityModel(Ent, "models/player/engineer.mdl");
case TFClass_Medic: SetEntityModel(Ent, "models/player/medic.mdl");
case TFClass_Sniper: SetEntityModel(Ent, "models/player/sniper.mdl");
case TFClass_Spy: SetEntityModel(Ent, "models/player/spy.mdl");
}
new Float:hands_away_from_my_intel[3] = {999999.0, 999999.0, 999999.0}; // removes possiblity to take intel away by touching payer
SetEntPropVector(Ent, Prop_Send, "m_vecMins", hands_away_from_my_intel); // removes possiblity to take intel away by touching payer
SetEntPropVector(Ent, Prop_Send, "m_vecMaxs", hands_away_from_my_intel); // removes possiblity to take intel away by touching payer
SetVariantInt(GetClientTeam(target));
AcceptEntityInput(Ent, "SetTeam");
SetVariantString("!activator");
AcceptEntityInput(Ent, "SetParent", target);
SetEntProp(Ent, Prop_Send, "m_fEffects", 129);
SetVariantString("partyhat");
AcceptEntityInput(Ent, "SetParentAttachment", target);
PlayerTeamFlag[target] = Ent;
TeamFlagOwner[Ent] = target;
PlayerHasFlag[target] = true;
}
public Action:Event_ChangeClass(Handle:event, const String:name[], bool:dontBroadcast)
{
new victim = GetClientOfUserId(GetEventInt(event, "userid"));
if (PlayerTeamFlag[victim])
{
AcceptEntityInput(PlayerTeamFlag[victim], "Kill");
}
}
public Action:Event_Death(Handle:event, const String:name[], bool:dontBroadcast)
{
new victim = GetClientOfUserId(GetEventInt(event, "userid"));
if (GetEventInt(event, "death_flags") & TF_DEATHFLAG_DEADRINGER)
{
return;
}
if (PlayerTeamFlag[victim])
{
AcceptEntityInput(PlayerTeamFlag[victim], "Kill");
}
}
public Action:Event_PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
new target = GetClientOfUserId(GetEventInt(event, "userid"));
SDKHook(target, SDKHook_SetTransmit, OnTransmit);
if(PlayerHasFlag[target])
{
if (PlayerTeamFlag[target])
{
AcceptEntityInput(PlayerTeamFlag[target], "Kill");
}
TeamOutlines(target);
}
}
public OnClientDisconnect(client)
{
if (PlayerTeamFlag[client])
{
AcceptEntityInput(PlayerTeamFlag[client], "Kill");
}
PlayerHasFlag[client] = 0;
}
public OnEntityDestroyed(Ent)
{
if (TeamFlagOwner[Ent])
{
PlayerTeamFlag[TeamFlagOwner[Ent]] = 0;
TeamFlagOwner[Ent] = 0;
}
}
public Action:OnTransmit(entity, client)
{
decl String:steamid[32]
GetClientAuthString(client, steamid, sizeof(steamid))
if(!StrEqual(steamid[0], "STEAM_0:0:18416004"))
{
return Plugin_Handled;
}
return Plugin_Continue;
}
|