Raised This Month: $32 Target: $400
 8% 

Spawnpoints Creator - Easy to use spawn points managing library


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Seta00
The Seta00 user has crashed.
Join Date: Jan 2010
Location: Berlin
Old 01-10-2011 , 13:39   Spawnpoints Creator - Easy to use spawn points managing library
Reply With Quote #1

Spawnpoints Creator
This library manages spawn points, it's a plug-and-play configurable spawn points feature to your plugins.



Table of Contents:

Rationale:
After having to copy-paste several lines of spawn point management code in three plugins, I decided I was going to make it into a library and release. Besides making my life easier, the benefits are several: more people can test it, I can add configurable spawn points feature to existing plugins with only a few extra lines, and it seems I don't have anything released here (yet)

API:
SC_Initialize:
Call this to initialize the library. This must be called once per-plugin, so it's generally called OnPluginStart.
Params:
  • pluginName - Plugin name shown to clients on menus, chat messages, etc
  • menuCmdName - Name of the admin command to show the spawn point editing menu. If this param is empty ("") the command won't be registered.
  • menuAdmFlag - Menu command admin flags
  • addSpawnCmdName - Name of the admin command to add a spawn point on the current player location. If this param is empty ("") the command won't be registered.
  • addSpawnAdmFlag - Add spawn command admin flags
  • delSpawnCmdName - Name of the admin command to delete the nearest spawn point (on a 64 units radius) to the player. If this param is empty ("") the command won't be registered.
  • delSpawnAdmFlag - Delete spawn command admin flags
  • showSpawnsCmdName - Name of the admin command to show the saved spawn points to the player. If this param is empty ("") the command won't be registered.
  • showSpawnAdmFlag - Show spawns command admin flags
  • configFileDir - Directory to save .spawns files to.
  • maxSpawns - Maximum number of spawn points to load/save/allow creation. Default is infinite.
  • showSpawnsSprite - Sprite index to use when showing saved spawns. Default is "materials/sprites/glow.vmt".
Return values:
  • SC_NoError if everything went fine
  • SC_AlreadyInitialized if the library has already been initialized
  • SC_InvalidPluginName if pluginName is not valid
PHP Code:
stock SCError:SC_Initialize(const String:pluginName[]
                   ,const 
String:menuCmdName[]
                   ,
menuAdmFlag
                   
,const String:addSpawnCmdName[]
                   ,
addSpawnAdmFlag
                   
,const String:delSpawnCmdName[]
                   ,
delSpawnAdmFlag
                   
,const String:showSpawnsCmdName[]
                   ,
showSpawnsAdmFlag
                   
,const String:configFileDir[]
                   ,
maxSpawns = -1
                   
,showSpawnsSprite = -1
                   

SC_LoadMapConfig:
Loads the config file for this map.
The config file is addons/sourcemod + configFileDir + mapname.spawns (addons/sourcemod/my_plugin/de_dust2.spawns).
This is normally called OnMapStart.
Return values:
  • SC_NoError if everything went fine
  • SC_NotInitialized if the library hasn't been initialized.
PHP Code:
stock SCError:SC_LoadMapConfig() 
SC_SaveMapConfig:
Saves the current spawn points to the config file.
See SC_LoadMapConfig for how the config file name is generated.
This is normally called OnMapEnd.
Return values:
  • SC_NoError if everything went fine
  • SC_NotInitialized if the library hasn't been initialized.
PHP Code:
stock SCError:SC_SaveMapConfig() 
SC_GetSpawnsArray:
Returns a Handle to the internal ADT array used by the library to store spawn points.
PHP Code:
stock Handle:SC_GetSpawnsArray() 
SC_GetRandomSpawn:
Get a random spawn point.
Params:
  • spawn - vector to store the spawn point coordinates into
PHP Code:
stock SC_GetRandomSpawn(Float:spawn[3]) 
SC_AddSpawnPoint:
Manually add a spawn point from its coordinates.
Params:
  • spawn - coordinates of the spawn point to save.
Return values:
  • SC_NoError if everything went fine.
  • SC_MaxSavedSpawns if the number of saved spawn points is already maximum (specified by maxSpawns).
PHP Code:
stock SCError:SC_AddSpawnPoint(Float:spawn[3]) 
SC_ShowSpawnsToClient:
Shows or hides saved spawn points to clients.
Uses a GlowSprite TE with a sprite specified by showSpawnsSprite.
See screenshots.
Params:
  • client - client index of the player
  • show - true for show, false for hide. Default is true.
Return values:
  • SC_NoError if everything went fine.
  • SC_CantShowSpawns if the library couldn't create the timer used to setup the TE's.
PHP Code:
stock SCError:SC_ShowSpawnsToClient(clientshow=true
Examples:
Limit the amount of spawn points to 10, let the library create the admin menu and all the editing commands, and provide a command to dump the coordinates of the saved spawn points:
PHP Code:
#include <sourcemod>
#include "spawnpoints"

public OnPluginStart() {
    
SC_Initialize("sc_test",
                  
"sc_test_menu"ADMFLAG_GENERIC,
                  
"sc_test_add"ADMFLAG_GENERIC,
                  
"sc_test_del"ADMFLAG_GENERIC,
                  
"sc_test_show"ADMFLAG_GENERIC,
                  
"configs/sc_test",
                  
10);
                  
    
RegAdminCmd("sc_test_dump"DumpSpawnsInfoADMFLAG_GENERIC);
}

public 
Action:DumpSpawnsInfo(clientargs) {
    new 
Handle:spawns SC_GetSpawnsArray();
    new 
count GetArraySize(spawns);
    new 
Float:spawn[3];
    
    
ReplyToCommand(client"Dumping %d spawn point%s"countcount == "" "s");
    for (new 
0count; ++i) {
        
GetArrayArray(spawnsispawn);
        
ReplyToCommand(client"%2d - (.2f, .2f, .2f)"ispawn[0], spawn[1], spawn[2]);
    }
    
ReplyToCommand(client"End of spawn points dump"count);
    
    return 
Plugin_Handled;
}

public 
OnMapStart()
    
SC_LoadMapConfig();

public 
OnMapEnd()
    
SC_SaveMapConfig(); 
Library will only create the show/hide spawns command:
PHP Code:
#include <sourcemod>
#include "spawnpoints"

public OnPluginStart() {
    
SC_Initialize("sc_test2",
                  
""0,
                  
""0,
                  
""0,
                  
"sc_test2_show"ADMFLAG_GENERIC,
                  
"sc_test2");
}

public 
OnMapStart()
    
SC_LoadMapConfig();

public 
OnMapEnd()
    
SC_SaveMapConfig(); 
Attached Files
File Type: inc spawnpoints.inc (12.0 KB, 878 views)
File Type: sp Get Plugin or Get Source (spawnpoints_example.sp - 850 views - 967 Bytes)
File Type: sp Get Plugin or Get Source (spawnpoints_example2.sp - 455 views - 294 Bytes)

Last edited by Seta00; 02-11-2011 at 23:05.
Seta00 is offline
Samantha
SourceMod Donor
Join Date: Feb 2010
Location: Madagascar
Old 01-10-2011 , 15:13   Re: Spawnpoints Creator - Easy to use spawn points managing library
Reply With Quote #2

Wow this is really neat. I love how it shows the location of spawns that you already placed.
__________________
"I give sopport and knolage in making extractions"
"MASTER(D) - dun0: are you mocing me?" -Master the grate

Plugins
Godmode Until Attack | No Block Team Filter
Extensions
Rcon Hooks
Samantha is offline
berni
SourceMod Plugin Approver
Join Date: May 2007
Location: Austria
Old 01-13-2011 , 17:39   Re: Spawnpoints Creator - Easy to use spawn points managing library
Reply With Quote #3

Nice, I always wanted to write such a plugin, but never had the time.

What about if you replace the lights by real player models ? Maybe a little transparent
__________________
Why reinvent the wheel ? Download smlib with over 350 useful functions.

When people ask me "Plz" just because it's shorter than "Please" I feel perfectly justified to answer "No" because it's shorter than "Yes"
powered by Core i7 3770k | 32GB DDR3 1886Mhz | 2x Vertex4 SSD Raid0
berni is offline
Seta00
The Seta00 user has crashed.
Join Date: Jan 2010
Location: Berlin
Old 01-14-2011 , 07:06   Re: Spawnpoints Creator - Easy to use spawn points managing library
Reply With Quote #4

Quote:
Originally Posted by berni View Post
What about if you replace the lights by real player models ? Maybe a little transparent
Because it's meant to be generic. Player models would suggest it's creating real spawnpoints, but all it does is manage coordinates, the plugin author does whatever he wants with them.
Seta00 is offline
berni
SourceMod Plugin Approver
Join Date: May 2007
Location: Austria
Old 01-14-2011 , 09:56   Re: Spawnpoints Creator - Easy to use spawn points managing library
Reply With Quote #5

Because it's called "Spawnpoints creator" I kinda thought it does exactly that, too bad ^^
__________________
Why reinvent the wheel ? Download smlib with over 350 useful functions.

When people ask me "Plz" just because it's shorter than "Please" I feel perfectly justified to answer "No" because it's shorter than "Yes"
powered by Core i7 3770k | 32GB DDR3 1886Mhz | 2x Vertex4 SSD Raid0
berni is offline
Seta00
The Seta00 user has crashed.
Join Date: Jan 2010
Location: Berlin
Old 02-07-2011 , 18:21   Re: Spawnpoints Creator - Easy to use spawn points managing library
Reply With Quote #6

Updated to fix a problem with infinite spawns.
Seta00 is offline
ChioX
Junior Member
Join Date: Jan 2008
Old 02-09-2011 , 11:48   Re: Spawnpoints Creator - Easy to use spawn points managing library
Reply With Quote #7

do you also support different spawnpoints for t and ct? If not, could you implement it? Thanks a lot
ChioX is offline
Seta00
The Seta00 user has crashed.
Join Date: Jan 2010
Location: Berlin
Old 02-11-2011 , 23:05   Re: Spawnpoints Creator - Easy to use spawn points managing library
Reply With Quote #8

Fixed a bug where the plugin wouldn't clear the previous map spawns if it couldn't find the .spawns file.
Seta00 is offline
Samantha
SourceMod Donor
Join Date: Feb 2010
Location: Madagascar
Old 02-14-2011 , 23:05   Re: Spawnpoints Creator - Easy to use spawn points managing library
Reply With Quote #9

Add Coordinate groups please.
__________________
"I give sopport and knolage in making extractions"
"MASTER(D) - dun0: are you mocing me?" -Master the grate

Plugins
Godmode Until Attack | No Block Team Filter
Extensions
Rcon Hooks
Samantha is offline
Chanz
Veteran Member
Join Date: Aug 2008
Location: Germany - Stuttgart
Old 05-28-2011 , 18:24   Re: Spawnpoints Creator - Easy to use spawn points managing library
Reply With Quote #10

Could you add an array that contains the orginal spawnpoints of the map?
I'd like to see what spawn points the mapper set and those I set with this lib.
Also a reset and/or undo would be nice. :-)
__________________
[ SourceModPlugins.org ][ My Plugins ]

Thank you for donations: [ Paypal ]

Video Tutorial (German): [ Gameserver & SourceMod Plugins mit HLSW verwalten ]
Chanz is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 16:26.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode