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

[REQUEST] Spawn Weapons across map


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
cigzag
AlliedModders Donor
Join Date: Nov 2014
Location: NZ
Old 05-06-2017 , 18:50   [REQUEST] Spawn Weapons across map
Reply With Quote #1

Hey, I was wondering if there is anyway I can have different config for every map, to spawn dropped custom weapons at different coordinates around the map. (customweapons txt) at a specific time in the round.
cigzag is offline
Drixevel
AlliedModders Donor
Join Date: Sep 2009
Location: Somewhere headbangin'
Old 05-06-2017 , 22:45   Re: [REQUEST] Spawn Weapons across map
Reply With Quote #2

If anyone wants to edit this plugin to add new stuff/convars/map configs support, be my guest.

Code:
#pragma semicolon 1
#pragma newdecls required

//Sourcemod Includes
#include <sourcemod>
#include <sdktools>

public Plugin myinfo = 
{
	name = "Spawn Weapons", 
	author = "Keith Warren (Drixevel)", 
	description = "Spawn weapons across the map on round start via a config.", 
	version = "1.0.0", 
	url = "http://www.drixevel.com/"
};

public void OnPluginStart()
{
	HookEvent("round_start", Event_OnRoundStart);
}

public void Event_OnRoundStart(Event event, const char[] name, bool dontBroadcast)
{
	char sPath[PLATFORM_MAX_PATH];
	BuildPath(Path_SM, sPath, sizeof(sPath), "configs/spawnweapons.cfg");
	
	KeyValues kv = CreateKeyValues("spawn_weapons");
	
	if (FileToKeyValues(kv, sPath) && KvGotoFirstSubKey(kv))
	{
		do
		{
			char sEntity[32];
			KvGetSectionName(kv, sEntity, sizeof(sEntity));
			
			float vecCoordinates[3];
			KvGetVector(kv, "coordinates", vecCoordinates);
			
			float vecAngles[3];
			KvGetVector(kv, "angles", vecAngles);
			
			int weapon = CreateEntityByName(sEntity);
			
			if (IsValidEntity(weapon))
			{
				DispatchSpawn(weapon);
				TeleportEntity(weapon, vecCoordinates, vecAngles, NULL_VECTOR);
			}
		}
		while (KvGotoNextKey(kv));
	}
	
	CloseHandle(kv);
}
Code:
"spawn_weapons"
{
	"weapon_awp"
	{
		"coordinates"	"0.0 0.0 0.0"
		"angles"		"0.0 0.0 0.0"
	}
}

Last edited by Drixevel; 05-06-2017 at 22:45.
Drixevel is offline
cigzag
AlliedModders Donor
Join Date: Nov 2014
Location: NZ
Old 05-06-2017 , 23:57   Re: [REQUEST] Spawn Weapons across map
Reply With Quote #3

Quote:
Originally Posted by Drixevel View Post
If anyone wants to edit this plugin to add new stuff/convars/map configs support, be my guest.

Code:
#pragma semicolon 1
#pragma newdecls required

//Sourcemod Includes
#include <sourcemod>
#include <sdktools>

public Plugin myinfo = 
{
	name = "Spawn Weapons", 
	author = "Keith Warren (Drixevel)", 
	description = "Spawn weapons across the map on round start via a config.", 
	version = "1.0.0", 
	url = "http://www.drixevel.com/"
};

public void OnPluginStart()
{
	HookEvent("round_start", Event_OnRoundStart);
}

public void Event_OnRoundStart(Event event, const char[] name, bool dontBroadcast)
{
	char sPath[PLATFORM_MAX_PATH];
	BuildPath(Path_SM, sPath, sizeof(sPath), "configs/spawnweapons.cfg");
	
	KeyValues kv = CreateKeyValues("spawn_weapons");
	
	if (FileToKeyValues(kv, sPath) && KvGotoFirstSubKey(kv))
	{
		do
		{
			char sEntity[32];
			KvGetSectionName(kv, sEntity, sizeof(sEntity));
			
			float vecCoordinates[3];
			KvGetVector(kv, "coordinates", vecCoordinates);
			
			float vecAngles[3];
			KvGetVector(kv, "angles", vecAngles);
			
			int weapon = CreateEntityByName(sEntity);
			
			if (IsValidEntity(weapon))
			{
				DispatchSpawn(weapon);
				TeleportEntity(weapon, vecCoordinates, vecAngles, NULL_VECTOR);
			}
		}
		while (KvGotoNextKey(kv));
	}
	
	CloseHandle(kv);
}
Code:
"spawn_weapons"
{
	"weapon_awp"
	{
		"coordinates"	"0.0 0.0 0.0"
		"angles"		"0.0 0.0 0.0"
	}
}
Cheers, I'm gonna see if this works for tf2, and see if I can add weapon index support.
cigzag 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 18:54.


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