AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Plugin/Gameplay Ideas and Requests (https://forums.alliedmods.net/forumdisplay.php?f=60)
-   -   [TF2] Activate on spawn thing (https://forums.alliedmods.net/showthread.php?t=280838)

StormishJustice 03-26-2016 10:43

[TF2] Activate on spawn thing
 
I was doing something in Red2Robotv2 and thought of an idea to enable giant (or small) forever until the player presses the command to revert back, problem is, i want for example the giant command to activate and notify the player that you need to respawn to be a giant (or small if was a giant), i would use IsPlayerAlive, but that will activate if the player is alive and not when the player respawns.

anyone has an idea how this is done? if so, then thanks in advance.

here's the code if you guys are asking.
Code:

public Action Command_Giant(int client, int args)
{
    g_bWantsToBeGiant[client] = true;
   
    if (GetClientTeam(client) ==3 && !g_bIsGiantRobot[client] && g_bWantsToBeGiant[client])
    {
        ReplyToCommand(client, "[Red2Robot] You will be a giant once you respawn.")
    }
    if (g_bIsGiantRobot[client])
    {
        ReplyToCommand(client, "[Red2Robot] You can't be a Giant Robot again because you already are.")
    }
    else if (GetClientTeam(client) ==3 && !g_bIsGiantRobot[client])
    {
        GiantRobot(client);
        ReplyToCommand(client, "[Red2Robot] You are now a Giant Robot!");
        ShowActivity2(client, "[Red2Robot] ", "%N is now a Giant Robot!", client);
    }
    else
    {
        ReplyToCommand(client, "[Red2Robot] You need to be in the BLU/Robots team in order to turn into a Giant Robot.");
    }
}


Chaosxk 03-26-2016 15:16

Re: [TF2] Activate on spawn thing
 
This?

Code:

bool g_bIsGiantRobot[MAXPLAYERS+1];

public void OnPluginStart()
{
    HookEvent("player_spawn", Event_PlayerSpawn);
}

public Action Event_PlayerSpawn(Handle event, const char[] sName, bool bDontBroadcast)
{
    int client = GetClientOfUserId(GetEventInt(event, "userid"));
    if(GetClientTeam(client) == 3 && g_bIsGiantRobot[client])
    {
        GiantRobot(client);
        ReplyToCommand(client, "[Red2Robot] You are now a Giant Robot!");
        ShowActivity2(client, "[Red2Robot] ", "%N is now a Giant Robot!", client);
    }
    g_bIsGiantRobot[client] = false;
}

public Action Command_Giant(int client, int args)
{
    if (GetClientTeam(client) == 3)
    {
        g_bIsGiantRobot[client] = true;
        ReplyToCommand(client, "[Red2Robot] You will be a giant once you respawn.")
    }
    else if (g_bIsGiantRobot[client])
    {
        ReplyToCommand(client, "[Red2Robot] You can't be a Giant Robot again because you already are.")
    }
    else
    {
        ReplyToCommand(client, "[Red2Robot] You need to be in the BLU/Robots team in order to turn into a Giant Robot.");
    }
}


StormishJustice 03-26-2016 16:44

Re: [TF2] Activate on spawn thing
 
Quote:

Originally Posted by Chaosxk (Post 2405862)
This?

Code:

bool g_bIsGiantRobot[MAXPLAYERS+1];

public void OnPluginStart()
{
    HookEvent("player_spawn", Event_PlayerSpawn);
}

public Action Event_PlayerSpawn(Handle event, const char[] sName, bool bDontBroadcast)
{
    int client = GetClientOfUserId(GetEventInt(event, "userid"));
    if(GetClientTeam(client) == 3 && g_bIsGiantRobot[client])
    {
        GiantRobot(client);
        ReplyToCommand(client, "[Red2Robot] You are now a Giant Robot!");
        ShowActivity2(client, "[Red2Robot] ", "%N is now a Giant Robot!", client);
    }
    g_bIsGiantRobot[client] = false;
}

public Action Command_Giant(int client, int args)
{
    if (GetClientTeam(client) == 3)
    {
        g_bIsGiantRobot[client] = true;
        ReplyToCommand(client, "[Red2Robot] You will be a giant once you respawn.")
    }
    else if (g_bIsGiantRobot[client])
    {
        ReplyToCommand(client, "[Red2Robot] You can't be a Giant Robot again because you already are.")
    }
    else
    {
        ReplyToCommand(client, "[Red2Robot] You need to be in the BLU/Robots team in order to turn into a Giant Robot.");
    }
}


Hey that seemed to work!

but i regret it and i changed my mind, but i will use that for later if i ever wanted to do so.

EDIT: I actually used that method and it's better, except i replaced the g_bIsGiantRobot thing to g_bWantsToBeGiant just incase.


All times are GMT -4. The time now is 21:11.

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