Raised This Month: $51 Target: $400
 12% 

[CSS/CSGO] Round Start Teleport Plugin - Multilocation


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
beetlejuice
Member
Join Date: Oct 2016
Old 07-04-2017 , 09:52   [CSS/CSGO] Round Start Teleport Plugin - Multilocation
Reply With Quote #1

So I have a map that has a small extra area that is apart the main map layout.
I would like to make a mod that will teleport all players to that area if there is less then 10 players on server on round start and use normal spawns if more then 10 players on server. While i managed to make round start counter and i even teleported players on right sides depending on their team...i am unable however imitate real spawns. What i mean by real spawns is that when players are teleported they are teleported all ct-s at one same place [first teleport coords] and all t-s at one same place [second teleport coords]. What I would like to do is make space between teammates, space between teleport spots and use more of them. Making players teleport individually...making them placed next to eachother like in real spawns.

Would be nice if i could choose teleport spots too for ct and t, like in cfg file or something but thats not necess...i can add spots manually in sp too and compile.

Here is what i got so far:

Code:
#pragma semicolon 1

#include <sourcemod>
#include <sdktools>
#include <cstrike>

new g_offsCollisionGroup;
new String:g_sCurrentMap[128];
new bool:latespawn = false;

public OnPluginStart()
{
	HookEvent("round_start", Event_RoundStart);
	HookEvent("round_end", Event_RoundEnd);
	HookEvent("player_spawn", Event_PlayerSpawn);
	
	latespawn = false;
	
	g_offsCollisionGroup = FindSendPropOffs("CBaseEntity", "m_CollisionGroup");
	GetCurrentMap(g_sCurrentMap, sizeof(g_sCurrentMap));
	
	LoadTranslations("common.phrases");
}

public Action:Event_PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
	new client = GetClientOfUserId(GetEventInt(event,"userid"));
	
        /// LATE JOIN PLAYERS TELEPORT
	if(IsValidClient(client) && latespawn) 
	{
		if(GetClientTeam(client) == 2)
			TeleportPlayer(client, 1);
		else if(GetClientTeam(client) == 3)
			TeleportPlayer(client, 2);
	}

	return Plugin_Continue;
}


public void Event_RoundEnd(Event event, const char[] name, bool dontBroadcast)
{
	latespawn = false; /// LATE JOIN PLAYERS TELEPORT
}

public void Event_RoundStart(Event event, const char[] name, bool dontBroadcast)
{
	new client = GetClientOfUserId(GetEventInt(event,"userid"));
	
	new counter = GetRealClientCount();

	/// TELEPORT PLAYERS ON ROUND START IF COUNT UNDER 10
	if(counter <= 10) 
	{
		if(GetClientTeam(client) == 2)
			TeleportPlayer(client, 1);
		else if(GetClientTeam(client) == 3)
			TeleportPlayer(client, 2);
	}
        else (counter > 10) 
	{
               /// DO NOTHING CAUSE THERE IS MORE THEN 10 PLAYERS NOW
	}
}

public void TeleportPlayer(target, team)
{
	UnblockEntity(target);

	new Float:pos[3], Float:ang[3] = {0.0, 0.0, 0.0};
	
	if(StrEqual(g_sCurrentMap, "de_molotov_hills", false))
	{
		if(team == 1)
		{
			pos = {-2828.02, -9.03, 310.59};
			ang = {0.0, -90.0, 0.0};
		}
		else
		{
			pos = {-2837.38, -1457.90, 310.81};
			ang = {0.0, 90.0, 0};
		}
	}
	else
	{
		return;
	}
	
	TeleportEntity(target, pos, ang, NULL_VECTOR);
}

stock GetRealClientCount() 
{
	new count = 0;
	
	for (new i = 1; i <= MaxClients; i++)
	{
		if (IsClientInGame(i) && !IsFakeClient(i) && GetClientTeam(i) > 1)
		{
			count++;
		}
	}

	return count;  
}

UnblockEntity(client)
{
	SetEntData(client, g_offsCollisionGroup, 2, 4, true);
}

bool:IsValidClient( client ) 
{
	if ( !( 1 <= client <= MaxClients ) || !IsClientInGame(client) ) 
		return false; 

	return true; 
}
Any help appreciated!
Attached Files
File Type: sp Get Plugin or Get Source (teleport_round_start.sp - 667 views - 2.2 KB)

Last edited by beetlejuice; 07-04-2017 at 10:32.
beetlejuice is offline
sim242
AlliedModders Donor
Join Date: Dec 2012
Location: England
Old 07-04-2017 , 15:26   Re: [CSS/CSGO] Round Start Teleport Plugin - Multilocation
Reply With Quote #2

Shouldn't this be in the scripting sub-forum?
__________________
Steam - Sim
Request a private plugin
Not accepting requests at this time
sim242 is offline
Send a message via Skype™ to sim242
beetlejuice
Member
Join Date: Oct 2016
Old 07-04-2017 , 15:49   Re: [CSS/CSGO] Round Start Teleport Plugin - Multilocation
Reply With Quote #3

yeah just saw i fucked up...well it is still a plugin and request kinda cause i cant finish it so if it ever ends up finished i think it can be under requests too? Moderator move?
beetlejuice is offline
sim242
AlliedModders Donor
Join Date: Dec 2012
Location: England
Old 07-05-2017 , 08:18   Re: [CSS/CSGO] Round Start Teleport Plugin - Multilocation
Reply With Quote #4

Yeah just thinking you'll probably get a lot more help under the scripting section
__________________
Steam - Sim
Request a private plugin
Not accepting requests at this time
sim242 is offline
Send a message via Skype™ to sim242
AmazingDay
Junior Member
Join Date: Jun 2017
Location: Book
Old 07-05-2017 , 10:06   Re: [CSS/CSGO] Round Start Teleport Plugin - Multilocation
Reply With Quote #5

if there are - than 10 players teleport to x place and if there are + than 10 players teleport to x place?
AmazingDay is offline
ambn
Veteran Member
Join Date: Feb 2015
Location: Fun servers
Old 07-05-2017 , 12:33   Re: [CSS/CSGO] Round Start Teleport Plugin - Multilocation
Reply With Quote #6

i did not really read your code carefully but regarding THIS there is no client index into round_start hook event so you probably have to loop though all clients into round_start and remove double job on player_spawn.
__________________

Last edited by ambn; 07-05-2017 at 12:36.
ambn is offline
beetlejuice
Member
Join Date: Oct 2016
Old 07-05-2017 , 16:43   Re: [CSS/CSGO] Round Start Teleport Plugin - Multilocation
Reply With Quote #7

Quote:
i did not really read your code carefully but regarding THIS there is no client index into round_start hook event so you probably have to loop though all clients into round_start and remove double job on player_spawn.
Code:
for (new i = 1; i <= MaxClients; i++)
{
    if (IsClientInGame(i) && IsPlayerAlive(i))
    {
           ////here code for teleport? How do i make the code that separates players that are teleported to be teleported next to eachother not inside eachother as i get with only one location.
    }
}


Quote:
if there are - than 10 players teleport to x place and if there are + than 10 players teleport to x place?
Yes...BUT! But once they are teleported they are inside eachother. For example if there was 5 ts and 5 cts to teleport to 2 different location...then they would spawn inside eachother, 5 ts inside eachother and 5 cts inside eachother....i want them teleported but next to eachother like real spawns make them spawn. Is that possible? I think it is just looping through players and make them teleport one by one on presetup teleport locations?



Quote:
Yeah just thinking you'll probably get a lot more help under the scripting section
Sure thanks


Thanks for helping me out!
beetlejuice is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 07-05-2017 , 17:24   Re: [CSS/CSGO] Round Start Teleport Plugin - Multilocation
Reply With Quote #8

I just want to throw out there you can use VScript and pack it into your map.

This way you dont need Sourcemod to acheive your outcome.

https://developer.valvesoftware.com/wiki/VScript
https://developer.valvesoftware.com/...ript_Functions
https://developer.valvesoftware.com/...cript_Examples

Edit: Your easiest method is to use trigger_teleports. On round start check your player count and enable the triggers if required.
__________________

Last edited by Neuro Toxin; 07-05-2017 at 17:27.
Neuro Toxin is offline
beetlejuice
Member
Join Date: Oct 2016
Old 07-05-2017 , 17:44   Re: [CSS/CSGO] Round Start Teleport Plugin - Multilocation
Reply With Quote #9

Quote:
I just want to throw out there you can use VScript and pack it into your map.

This way you dont need Sourcemod to acheive your outcome.

https://developer.valvesoftware.com/wiki/VScript
https://developer.valvesoftware.com/...ript_Functions
https://developer.valvesoftware.com/...cript_Examples

Edit: Your easiest method is to use trigger_teleports. On round start check your player count and enable the triggers if required.
Thx Neuro Toxin, that is really interesting indeed.
Can you please expand on it and provide me with example of how to activate/deactivate trigger_teleports using sourcemod?
I would place trigger teleport under spawns in hammer and activate them on round end so on round start player is teleported. Thants the idea if possible...
beetlejuice is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 07-05-2017 , 17:54   Re: [CSS/CSGO] Round Start Teleport Plugin - Multilocation
Reply With Quote #10

I can provide examples tomorrow.

It's 100% possible.
__________________
Neuro Toxin is offline
Reply



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 06:29.


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