MASSIVE UPDATE - Now Requires SMLIB
http://forums.alliedmods.net/showthread.php?p=1398699
Please Note that this is for compilation purposes only. You do not need this for running the plugin.
A little background on the plugin
This is my first public sourcemod plugin ever! Basically I wanted admins on my Zombiemod server to be able to spawn props. However each time I ran into a snag when attempting this with Eventscripts. I could only spawn Prop_Physics and Prop_Physics_Dynamic, which isn't very useful.
So I made this plugin! It allows Server Admins to spawn props which are defined in a text file (working example included). I wanted a safe way for admins to spawn props so I learnt a bit of Sourcepawn and here is the result!
Special Thanks
Model Menu - by pRED* - Without this, it would have taken me much longer to get my head around Keyvalues and Menus.
RP_Tools - I can't remember where I obtained this, but it's thanks to this that I know how to make props spawn in a nice way! It was nearly perfect for me, however not very user friendly.
-------------------------
Installation:
Extract
om_propspawn.smx to
addons/sourcemod/plugins
Extract
om_public_props.txt to
addons/sourcemod/configs
Configuration
Open om_public_props.txt and you'll find this:
Code:
"Props"
{
"Vending Machine"
{
"model" "models/props/cs_office/vending_machine.mdl"
"height" "50"
"price" "15"
}
"Sofa"
{
"model" "models/props/cs_office/sofa.mdl"
"price" "5"
}
"Book Shelf"
{
"model" "models/props/cs_office/bookshelf1.mdl"
}
"Dryer Box"
{
"model" "models/props/cs_assault/dryer_box.mdl"
"price" "5"
}
}
As you can see each prop can now have a "price" option. This sets the price for the prop if om_prop_public is set to 0. If there is no price option set in the file for a prop, it will be free to spawn.
If you wanted to change the height at which the individual prop spawned at:
Code:
"Props"
{
"Vending Machine"
{
"model" "models/props/cs_office/vending_machine.mdl"
"height" "50"
"adminonly" "1" //Means it's admin only if set to 1
}
}
Commands
!props (or /props) - Brings up the menu for spawning props. - Requires Slay Flag
!credits (or /credits) - Shows you how many credits you have. (Public)
!om_admin_credits <name> <credits> - Allows you to modify player credits. Minus numbers can be used to remove credits.
!om_remove_props - Removes all props created by players
ConVars
om_prop_public <number> -0 means anyone can use this plugin. 1 means admins only
om_prop_teamonly <number> - 0 is no restrictions, 1 is Terrorist and 2 is CT. Default: 0
om_propspawn_version - Shows the plugin version
om_prop_credits <number> - The number of credits a player should get when they spawn. Default: 20
om_prop_removeondeath <number> - 1 means props are removed on death, 0 means they aren't
om_prop_addcreditsonkill <number> - 1 means credits are added when a player kills someone, 0 means they aren't.
om_prop_killcredits <number> - The number of credits added when a player kills someone. Default: 5
--------------------------------
And that's all I can think of putting down!
Currently I have only tested this on CS:S but I don't see why it wouldn't work on any other source game (TF2 for instance), but i'm a newb at Sourcepawn so don't expect it to!
Currently tested and working on:
Counter-Strike:Source
Team Fortress 2
If anyone tests this on other games, please tell me if it loaded successfully and functioned properly and I will add the game to the list!
Attached should be:
om_propspawn.sp (thus the smx)
om_public_props.txt
Little Note:
All props spawned are prop_physics_override
Changelog:
Code:
V1.0.0: Initial Release
V1.0.1:
Added new "height" string to define custom spawn heights for each prop.
Example:
"Props"
{
"Vending Machine"
{
"model" "models/props/cs_office/vending_machine.mdl"
"height" "50"
}
}
V2.0.0
Rewrite of plugin:
- It now works on a system of credits.
- Server Administrators can set whether or not normal players can spawn props (at a price).
- 2 new ConVars added.
- Team Only Setting added (Very useful for Zombiemod.) Spectators cannot spawn props anymore, no matter what value this ConVar is.
- Replaced om_props.txt with om_public_props.txt
- Uses ClientPrefs to manage credits.
V3.0.0
Another Rewrite of plugin:
- Fixed a lot of stuff
- Clientprefs no longer used
- SMLib is now used
- Fixed Admin Only commands (I hope)
- Added ways of removing props
- Props are removed on client disconnect
- Added "adminonly" property for props (see example)
- Added a way for credits to be added when a player kills someone
V3.0.2
- Made the menu appear automatically after spawning a prop
- Fixed Team restriction issues
- Fixed props not being named properly
- Fixed props not actually being deleted when using the command
- Added debug mode in source code