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

[CSS/CSGO] Round Start Teleport Plugin - Multilocation


Post New Thread Reply   
 
Thread Tools Display Modes
beetlejuice
Member
Join Date: Oct 2016
Old 07-05-2017 , 18:06   Re: [CSS/CSGO] Round Start Teleport Plugin - Multilocation
Reply With Quote #11

Alright, roger. Thank you very much.
beetlejuice is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 07-06-2017 , 09:11   Re: [CSS/CSGO] Round Start Teleport Plugin - Multilocation
Reply With Quote #12

Ok, A basic VScript run down. It's been a while, so I've thrown this together based on some other scripts I've done. Nothing is tested so you might need to debug and fix some small bugs.

This is a great page!!!

First and foremost, VScripts are located in the `/csgo/scripts/vscripts/` folder.
1. Make a folder named your maps name in the vscripts folder
VScript files have a .nut extension. I have some really complex scripts in some maps so I've got into a habit of naming the main script folder `main.nut`.
2. Make a file named `main.nut` in your maps VScript folder from step one.
Within your map, you need an entity to execute the script to make it run. I use a logic_relay entity myself, but almost every entity type will work.
3. Open your map in Hammer and add a logic_relay entity
We set the `Entity Scripts` property of the logic_relay to the path of the script file.
4. Set `Entity Scripts` to <map folder from step 1>/main.nut


Now each time a round starts, the logic_relay is created, and the script is executed. This serves really well because we can edit the script on the server, save it, restart the round, and the updated script executes. Much better then compiling the map again to make one little change!

5. Compile your map with the new logic_relay entity pointing at your .nut script and let the game launch the map in developer mode.

So lets get into some VScripting.

6. Open up your .nut file in your favorite text editor

I generally start each script with a print call to state the scripting is executing.

Code:
printl("Executing <MapName> VScript...");
If you save and use `endround` in the game console, you should see this message print to the console on every round start as the logic_relay entity is created (prints to server console on a proper dedicated server).

You will need to loop through players and work out the player count so you can figure out if you want to enable your teleports.

We will create a function for this so we can use local variables in the function scope that will be removed when the function ends. I'll name the function EnableTeleportsIfRequired.

Code:
::EnableTeleportsIfRequired <- function()
{
	local player = null;
	local team = null;
	local CS_TEAM_CT = 3;
	local CS_TEAM_T = 2;
	local playercount = 0;

	while ((player = Entities.FindByClassname(player, "player")) != null)
	{
		team = player.GetTeam();

		if (team == CS_TEAM_T || team == CS_TEAM_CT)
		{
			playercount++;
		}
	}
}
Next we need to call the Enable input of the teleports if the required player count is reached. We use the EntFire function as found here.


Code:
::EnableTeleportsIfRequired <- function()
{
	...

	if (playercount <= 10)
	{
		EntFire("name_of_teleport_trigger", "Enable");
	}
}
At the end of the script we will call the EnableTeleportsIfRequired function.

Code:
printl("Executing <MapName> VScript...");

::EnableTeleportsIfRequired <- function()
{
	...
}

EnableTeleportsIfRequired();
So the entire snippet looks like:

Code:
printl("Executing <MapName> VScript...");

::EnableTeleportsIfRequired <- function()
{
	local player = null;
	local team = null;
	local CS_TEAM_CT = 3;
	local CS_TEAM_T = 2;
	local playercount = 0;

	while ((player = Entities.FindByClassname(player, "player")) != null)
	{
		team = player.GetTeam();

		if (team == CS_TEAM_T || team == CS_TEAM_CT)
		{
			playercount++;
		}
	}

	if (playercount <= 10)
	{
		EntFire("name_of_teleport_trigger", "Enable");
	}
}

EnableTeleportsIfRequired();
So the fundamental idea is:

1. Attach the VScript nut file to a logic_relay entity
2. Each round start the logic_relay entity is created and the script executes (consider the script to be called inside a round_start event hook)
3. We declare a function that does our work so the local variables are trashed
4. We call the function at the end of the script

My scripts are really large and used to control an entire maps input/outputs because:

1. You can edit the script and restart the round to test the changes without recompiling a map
2. If you dont pack the scripts into your map, people cant join your servers and steal the maps because the input/output logic is safely stored on the server

When your done, compile the map and build cubemaps/stringtables/ect then pack the vscripts into it!!!!
__________________

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

Neuro Toxin, Thank you for this amazing tutorial!

i got it working in csgo!
I didnt even knew this existed and it does the job perfectly in csgo!
And you are right this is perfect for protecting maps

I also have css server needing this,
But there is no Vscripts for css unfortunately valve just added it to some games.

So i built map in css hammer as i did in csgo and i am trying to disable teleports on round end so on round start players are teleported [or teleport disabled] depending of player count.

I got this:
Code:
public void Event_RoundEnd(Event event, const char[] name, bool dontBroadcast)
{
    latespawn = false;
    new counter2 = GetRealClientCount();

    new entity;
    decl String:targetname[256];
    
    if(counter2 > 10)
    {
        if ((entity = FindEntityByClassname(entity, "trigger_teleport")) != -1)
        {
            GetEntPropString(entity, Prop_Data, "m_iName", targetname, sizeof(targetname));
            Format(targetname, sizeof(targetname), "%s_disabled", targetname);
            DispatchKeyValue(entity, "targetname", targetname);
        }
    }
    else
    {
        if ((entity = FindEntityByClassname(entity, "trigger_teleport")) != -1)
        {
            GetEntPropString(entity, Prop_Data, "m_iName", targetname, sizeof(targetname));
            ReplaceString(targetname, sizeof(targetname), "_disabled", "", true);
            DispatchKeyValue(entity, "targetname", targetname);
        }
    }

}

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

	return count;  
}
Of course... it is not working :\

Simply need a code that will trigger teleport on/off on round_end so next round starts in different part of map (i dont think i can do that on round start as it is too late). Thanks

Last edited by beetlejuice; 07-06-2017 at 23:13.
beetlejuice is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 07-06-2017 , 23:22   Re: [CSS/CSGO] Round Start Teleport Plugin - Multilocation
Reply With Quote #14

You can still do this all in hammer.

This is based on memory and I can provide an example in csgo hammer if you cant work it out.

1. Leave the teleport triggers disabled on spawn.
2. Create a math counter
3. Wrap trigger multiples? around each spawn
4. Goto inputs on the trigger
5. OnStartTouch -> math counter name -> add 1
6. Goto math counter inputs
7. OnValue -> teleport name -> enable

Edit: i think you need a relay or two to call the check value input on the math counter.

Eg. On trigger start touch call relay then disable it. Then the following start touches wont trigger the disabled relay.

In the relay outputs wait .1 and call the math counter
__________________

Last edited by Neuro Toxin; 07-06-2017 at 23:29.
Neuro Toxin is offline
beetlejuice
Member
Join Date: Oct 2016
Old 07-08-2017 , 15:28   Re: [CSS/CSGO] Round Start Teleport Plugin - Multilocation
Reply With Quote #15

Thanks again for sharing Neuro Toxin.

Ok so you made me lift my skill bar in hammer hehe
I spent at least, at least 6-7h trying to make this work properly.

And i got it to work a little bit different then what you suggested. (with one bug online)

1.Created trigger multiple, logic_compare and game_zone_player
2.Output trigger_multiple to game_zone_player (https://developer.valvesoftware.com/...me_zone_player) to trigger player count on round end. Basically created brush, painted it invisible and turned it into game_zone_player that counts all players inside that brush.
3.output the result of count to logic_compare with delay of 0.8sec. Logic_compare then outputs to all trigger_teleports (32 of them inside each spawn, which i named same) disabling/enabling depending on count before round start with 1.2 sec delayé

And it works perfectly offline with bots. It is not idea cause of teleport delay on spawn but it works.
Tested it with all numbers of bots from 1 to 32.

Online however is different story, some bots/players get teleported and some never get teleported....maybe is my delay time between outputs and checks maybe it is not the right method.

I ll try math_counters also to see what i get.
beetlejuice is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 07-08-2017 , 19:44   Re: [CSS/CSGO] Round Start Teleport Plugin - Multilocation
Reply With Quote #16

1. You should be painting all triggers the trigger texture.
2. Wrap your teleport triggers around the entire spawn (you would have two in total)
3. I haven't played with game_zone_player but it looks like the output PlayersInCount can be sent directly to a logic_compare

I'll have a play around and see what I come back with...
__________________

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

Done

Code:
1. Leave the teleport triggers disabled on spawn.
2. Create a math counter
3. Wrap trigger multiples? around each spawn
4. Goto inputs on the trigger
5. OnStartTouch -> math counter name -> add 1
6. Goto math counter inputs
7. OnValue -> teleport name -> enable
Your option works best!

Can thank you enough for detailed help on the way...

Wanna send ya $$ for beer ...donation link?
beetlejuice is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 07-08-2017 , 23:37   Re: [CSS/CSGO] Round Start Teleport Plugin - Multilocation
Reply With Quote #18

Thanks a bunch!

Donate


Edit: I've tried using game_zone_player, however, the CountPlayersInZone input doesn't seem to fire any outputs for some reason.
__________________

Last edited by Neuro Toxin; 07-08-2017 at 23:54.
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 16:07.


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