This plugin is meant to turn weapons transparent so they're entirely in your face.
The idea is to be able to see the weapon without the weapon blocking your view!
this is the original code
Syntax: Select all
#include <sourcemod>
#include <tf2_stocks>
#include <morecolors>
#pragma semicolon 1
#pragma newdecls required
#define MXPLYR MAXPLAYERS+1
int iProPlayer[ MXPLYR ];
public Plugin myinfo =
{
name = "WepAlphanator",
author = "Assyrian/Nergal",
description = "makes weapons transparent",
version = "1.0",
url = "http://www.sourcemod.net/"
}
public void OnPluginStart()
{
RegConsoleCmd("sm_pro", CommandSetWepAlpha, "Weapon Alpha");
RegConsoleCmd("sm_angles", CommandInfo, "Weapon Angles");
RegAdminCmd("sm_adpro", CommandSetAdminWepAlpha, ADMFLAG_SLAY, "Admin Weapon Alpha");
HookEvent("player_spawn", Eventery);
HookEvent("post_inventory_application", Eventery);
for (int i = 1; i <= MaxClients; i++)
{
if ( !IsValidClient(i) ) continue;
OnClientPutInServer(i);
}
}
public void OnClientPutInServer( int client )
{
iProPlayer[client] = -1;
}
public Action CommandInfo(int client, int args)
{
float flVector[3]; GetClientEyeAngles(client, flVector);
CPrintToChat(client, "{green}Your Eye Angles: x:%f, y:%f, z:%f", flVector[0], flVector[1], flVector[2]);
GetClientEyePosition(client, flVector);
CPrintToChat(client, "{green}Your Eye Position: x:%f, y:%f, z:%f", flVector[0], flVector[1], flVector[2]);
GetEntPropVector(client, Prop_Data, "m_vecAbsOrigin", flVector);
CPrintToChat(client, "{green}Your Absolute Origin from Property Vector: x:%f, y:%f, z:%f", flVector[0], flVector[1], flVector[2]);
GetEntPropVector(client, Prop_Send, "m_vecMaxs", flVector);
CPrintToChat(client, "{green}Your Vector Max Size: x:%f, y:%f, z:%f", flVector[0], flVector[1], flVector[2]);
GetEntPropVector(client, Prop_Send, "m_vecMins", flVector);
CPrintToChat(client, "{green}Your Vector Min Size: x:%f, y:%f, z:%f", flVector[0], flVector[1], flVector[2]);
GetEntPropVector(client, Prop_Data, "m_angAbsRotation", flVector);
CPrintToChat(client, "{green}Your Absolute Angle Rotation: x:%f, y:%f, z:%f", flVector[0], flVector[1], flVector[2]);
GetEntPropVector(client, Prop_Data, "m_vecVelocity", flVector);
CPrintToChat(client, "{green}Your Velocity: x:%f, y:%f, z:%f", flVector[0], flVector[1], flVector[2]);
return Plugin_Continue;
}
public Action CommandSetWepAlpha(int client, int args)
{
if (args < 1)
{
ReplyToCommand(client, "[Alpha Weps] Usage: !pro <0-255>");
return Plugin_Handled;
}
char number[8]; GetCmdArg(1, number, sizeof(number));
int maxalpha = StringToInt(number);
iProPlayer[client] = maxalpha;
SetWeaponInvis(client, maxalpha);
CPrintToChat(client, "{green}You've Turned Your Weapon Transparent!");
return Plugin_Continue;
}
public Action CommandSetAdminWepAlpha(int client, int args)
{
if (args < 2)
{
ReplyToCommand(client, "[Alpha Weps] Usage: !adpro <target> <0-255>");
return Plugin_Handled;
}
char szTargetname[64]; GetCmdArg(1, szTargetname, sizeof(szTargetname));
char szNum[64]; GetCmdArg(2, szNum, sizeof(szNum));
int maxalpha = StringToInt(szNum);
char target_name[MAX_TARGET_LENGTH];
int target_list[MAXPLAYERS+1], target_count;
bool tn_is_ml;
if ( (target_count = ProcessTargetString(szTargetname, client, target_list, MAXPLAYERS, COMMAND_FILTER_ALIVE, target_name, sizeof(target_name), tn_is_ml)) <= 0 )
{
ReplyToTargetError(client, target_count);
return Plugin_Handled;
}
for (int i = 0; i < target_count; i++)
{
if ( IsValidClient(target_list[i]) && IsPlayerAlive(target_list[i]) )
{
SetWeaponInvis(target_list[i], maxalpha);
CPrintToChat(target_list[i], "{unusual}Your Weapon Is Transparent!");
}
}
return Plugin_Handled;
}
public Action Eventery(Event event, const char[] name, bool dontBroadcast)
{
int i = GetClientOfUserId( event.GetInt("userid") );
if ( IsValidClient(i) )
{
if ( iProPlayer[i] != -1 ) SetWeaponInvis( i, iProPlayer[i] );
}
return Plugin_Continue;
}
stock void SetWeaponInvis(int client, int &alpha)
{
for (int i = 0; i < 5; i++)
{
int entity = GetPlayerWeaponSlot(client, i);
if ( IsValidEdict(entity) && IsValidEntity(entity) )
{
if (alpha < 0) alpha = 0;
else if (alpha > 255) alpha = 255;
SetEntityRenderMode(entity, RENDER_TRANSCOLOR);
SetEntityRenderColor(entity, 150, 150, 150, alpha);
}
}
return;
}
stock bool IsValidClient(int client, bool replaycheck = true)
{
if ( client <= 0 || client > MaxClients) return false;
if ( !IsClientInGame(client) ) return false;
if ( GetEntProp(client, Prop_Send, "m_bIsCoaching") ) return false;
if ( replaycheck ) if ( IsClientSourceTV(client) || IsClientReplay(client) ) return false;
return true;
}
and here's the ported code I somewhat made and copypasta'd some code from
Syntax: Select all
# Python Imports
#from collections import defaultdict
# SourcePython imports
from players.entity import PlayerEntity
from players.helpers import userid_from_index
from players.helpers import index_from_userid
from weapons.entity import WeaponEntity
from entities.constants import RenderMode
from events import Event
from colors import Color
from commands.say import SayCommand
from cvars.public import PublicConVar
from plugins.info import PluginInfo
info = PluginInfo()
info.name = "AlphaWeps"
info.author = "Nergal/Assyrian"
info.version = "1.0"
info.basename = "alphaweps"
info.variable = info.basename + "_version"
info.convar = PublicConVar(info.variable, info.version, 0, info.name + " Version")
#create a list
iProPlayer = [i+1 for i in range(66)]
@SayCommand('!pro')
def pro_command(index, teamonly, CCommand):
text = CCommand[1].split()
if len(text) < 0:
return True
iProPlayer[index] = int(text)
set_weapon_invis(userid_from_index(index), iProPlayer[index])
@Event
def player_connect(game_event):
userid = game_event.get_int('userid')
set_playerlist(userid)
@Event
def player_disconnect(game_event):
userid = game_event.get_int('userid')
set_playerlist(userid)
@Event
def player_spawn(game_event):
eventery(game_event.get_int('userid'))
@Event
def post_inventory_application(game_event):
eventery(game_event.get_int('userid'))
def eventery(userid):
index = index_from_userid(userid)
if iProPlayer[index] is not None:
set_weapon_invis(userid, iProPlayer[userid])
def set_playerlist(userid):
index = index_from_userid(userid)
iProPlayer[index] = None
def set_weapon_invis(userid, alpha):
try:
index = index_of_userid(userid)
except ValueError:
print('Wrong userid: ', userid)
player = PlayerEntity(index)
alpha = max(min(alpha, 255), 0)
for weapon_index in player.weapon_indexes():
entity = WeaponEntity(weapon_index)
entity.render_mode = RenderMode.TRANS_COLOR
entity.color = Color(150, 150, 150, alpha)
The plugin all loads fine but when I try out the command, it doesn't do anything but make me look stupid typing it in with everybody else typing it themselves (lol)
what did I do wrong?