ATTACHABLES IS BROKEN THEREFORE THIS IS BROKEN
SO!
People requested for Randomizer to have visible weapons.
I said "nowai, needs attachables, and I'm not including attachables in randomizer as a requirement!"
So then I found out how to make it optional.
So here.
Natives for giving weapons to clients.
What it does is, all plugins that use this can add the native VisWep_GiveWeapon(client, slot, model)
after each time they give a weapon.
It will automatically organize each slot's attachable entity, as well as invis/vis the slots depending on OnWeaponSwitch from SDKHooks.
So, requires SDKHooks and Attachables.
http://forums.alliedmods.net/showthread.php?t=106748
https://forums.alliedmods.net/showthread.php?t=126577
Cvar:
visibleweapons_version (default 1.2)
Native:
PHP Code:
/**
* Sets up an attachable for a slot.
*
* @param client Client Index. Does an alive/in-game/valid check in the function
* @param slot The weapon slot for the attachable.
* @param model The model you want to attach, if custom. Otherwise, put the item index here, like "169".
* @noreturn
*/
native VisWep_GiveWeapon(client, slot, const String:model[]);
If you wanna make it optional, add a new bool near the top (thanks to _1Swatty for this stuff)
new bool:visibleweapons = false;
OnPluginStart, do this:
visibleweapons = LibraryExists("visweps");
And then, OnLibraryAdded:
if (StrEqual(name, "visweps")) visibleweapons = true;
OnLibraryRemoved:
if (StrEqual(name, "visweps")) visibleweapons = false;
Then put the if (visibleweapons) in front of each time you use VisWep_GiveWeapon so it skips over it if visibleweapons is not on the server.
NOTE: You CAN put in a number for the model name, and it will attempt to find the model associated with that item index. E.g. 312 = brass beast. Will auto-set the brass beast model.
Look at
http://forums.alliedmods.net/showthread.php?t=141962 and
https://forums.alliedmods.net/showthread.php?t=139069
for examples.
TL;DR if you're a developer and you put this native in a giveweapon plugin at each time the weapon is given, it will make the weapon visible and auto-invis it if the weapon is not out.
Also does the banner backpacks, and stuff.
To the people that are here for Randomizer and Give Weapon: just install the plugin, and SDKHooks and Attachables.
ALSO to such persons, models for the Rebel's Curse and Khopesh Climber.
Credit to Mecha the Slag for some/most of the basic code.
Changelog
Code:
2/24/2011(v1.2)
*Added wearable weapon support (send it as slot 6 to make it a wearable instead of a normal weapon)
*Added worldmodels for index 142(gunslinger) and index 5/195(fists)
*Razorback and Danger Shield models (requires latest attachables)
*Rift weapons now get models (but not their actual models, yet)
*Flamethrower fixed
*Upgradeable weapons (index used for renamed) now have models
*Some changes to the hiding function to hide better on disguise, etc. Also, dead ringer hide. But I'm not sure if I'm doing it right.
01/07/2011(v1.1)
*Fixed function with custom model usage (forgot an strcopy somewhere in there)
*Uh... Added a model for Ludmila from GiveWeapon/Randomizer: it's a sasha with the natascha strap on the side. So it's different from both.
*Some minor changes in capitalization, cleanup as suggested by Kevin_b_er.
*In the .inc file, added #if !defined REQUIRE_PLUGIN over the SetNTVOptional line (#endif after). Just because that seemed a convention.
12/18/2010 (v1.0)
*First Release
ANOTHER NOTE: If you are running Sidewinder or TFDodgeball, this will not work. Why? Both use the CEntity framework for their homing, which interferes with attachables in some way, making the attachables invisible again. Sadface. Asherkin said he is going to work on it some time. In this thread. Somewhere.