AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   [CSS/CSGO] Round Start Teleport Plugin - Multilocation (https://forums.alliedmods.net/showthread.php?t=299139)

beetlejuice 07-04-2017 09:52

[CSS/CSGO] Round Start Teleport Plugin - Multilocation
 
1 Attachment(s)
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!

sim242 07-04-2017 15:26

Re: [CSS/CSGO] Round Start Teleport Plugin - Multilocation
 
Shouldn't this be in the scripting sub-forum?

beetlejuice 07-04-2017 15:49

Re: [CSS/CSGO] Round Start Teleport Plugin - Multilocation
 
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?

sim242 07-05-2017 08:18

Re: [CSS/CSGO] Round Start Teleport Plugin - Multilocation
 
Yeah just thinking you'll probably get a lot more help under the scripting section :)

AmazingDay 07-05-2017 10:06

Re: [CSS/CSGO] Round Start Teleport Plugin - Multilocation
 
if there are - than 10 players teleport to x place and if there are + than 10 players teleport to x place?

ambn 07-05-2017 12:33

Re: [CSS/CSGO] Round Start Teleport Plugin - Multilocation
 
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.

beetlejuice 07-05-2017 16:43

Re: [CSS/CSGO] Round Start Teleport Plugin - Multilocation
 
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!

Neuro Toxin 07-05-2017 17:24

Re: [CSS/CSGO] Round Start Teleport Plugin - Multilocation
 
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.

beetlejuice 07-05-2017 17:44

Re: [CSS/CSGO] Round Start Teleport Plugin - Multilocation
 
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...

Neuro Toxin 07-05-2017 17:54

Re: [CSS/CSGO] Round Start Teleport Plugin - Multilocation
 
I can provide examples tomorrow.

It's 100% possible.


All times are GMT -4. The time now is 18:46.

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