Raised This Month: $404 Target: $400
 101% 

[TF2] Put Merasmus on Gray Team


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
PC Gamer
Senior Member
Join Date: Mar 2014
Old 10-09-2018 , 16:57   [TF2] Put Merasmus on Gray Team
Reply With Quote #1

Coders,

How can I place Merasmus on the Gray Team (Spectator, Team 0)?

Every effort on my part to put Merasmus on Spectator team using code
results in Merasmus not functioning correctly or crashing server on disconnect.

Can you help? The goal is for the bewizard plugin to know the players
original team (red or blue), make the player Merasmus on the gray team,
and on death place the player back on their original team as a player.

The desired effect is achieved if I use two commands separately:
1. First, use the !gray command with the gray plugin written by Dachtone
2. Next, use the !bewizard command from the bewizard plugin

Goal: Use only the bewizard plugin to achieve the desired effect.

bewizard code:
PHP Code:
#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>
#include <tf2>
#include <tf2_stocks>
#include <tf2attributes>
#include <tf2items>
#include <tf2items_giveweapon>

#define PLUGIN_VERSION "1.0"

#define HHH        "models/bots/merasmus/merasmus.mdl"
#define BOMBMODEL        "models/props_lakeside_event/bomb_temp.mdl"
#define SPAWN    "vo/halloween_merasmus/sf12_appears04.mp3"
#define DEATH    "vo/halloween_merasmus/sf12_defeated01.mp3"

#define MERASMUS "models/bots/merasmus/merasmus.mdl"
#define DOOM1    "vo/halloween_merasmus/sf12_appears04.mp3"
#define DOOM2    "vo/halloween_merasmus/sf12_appears09.mp3"
#define DOOM3    "vo/halloween_merasmus/sf12_appears01.mp3"
#define DOOM4            "vo/halloween_merasmus/sf12_appears08.mp3"

#define DEATH1    "vo/halloween_merasmus/sf12_defeated01.mp3"
#define DEATH2    "vo/halloween_merasmus/sf12_defeated06.mp3"
#define DEATH3    "vo/halloween_merasmus/sf12_defeated08.mp3"

#define HELLFIRE "vo/halloween_merasmus/sf12_ranged_attack08.mp3"
#define HELLFIRE2 "vo/halloween_merasmus/sf12_ranged_attack04.mp3"
#define HELLFIRE3 "vo/halloween_merasmus/sf12_ranged_attack05.mp3"

#define BOMB            "vo/halloween_merasmus/sf12_bombinomicon03.mp3"
#define BOMB2            "vo/halloween_merasmus/sf12_bombinomicon09.mp3"
#define BOMB3            "vo/halloween_merasmus/sf12_bombinomicon11.mp3"
#define BOMB4            "vo/halloween_merasmus/sf12_bombinomicon14.mp3"

#define LOL            "vo/halloween_merasmus/sf12_combat_idle01.mp3"
#define LOL2            "vo/halloween_merasmus/sf12_combat_idle02.mp3"

new iLastRand;
new 
Handle:g_hCvarThirdPerson;
new 
bool:g_bIsHHH[MAXPLAYERS 1];
new 
bool:IsTaunting[MAXPLAYERS 1];
new 
bool:ms false;

public 
Plugin:myinfo 
{
    
name "[TF2] Be the Wizard Merasmus",
    
author "Starman4xz, Mitch, Pelipoika, FlamingSarge, Tylerst, modified by PC Gamer",
    
description "Play as the Wizard Merasmus",
    
version PLUGIN_VERSION,
    
url "www.sourcemod.com"
}

public 
OnPluginStart()
{
    
LoadTranslations("common.phrases");
    
g_hCvarThirdPerson CreateConVar("bewizard_thirdperson""1""Whether or not wizard ought to be in third-person"0true0.0true1.0);
    
    
RegAdminCmd("sm_bewizard"Command_wizardADMFLAG_SLAY"It's a good time to run");

    
HookEvent("post_inventory_application"EventInventoryApplicationEventHookMode_Post);
    
HookEvent("player_death"Event_DeathEventHookMode_Post);

}

public 
OnClientPutInServer(client)
{
    
OnClientDisconnect_Post(client);
}

public 
OnClientDisconnect_Post(client)
{
    if (
g_bIsHHH[client])
    {
        
g_bIsHHH[client] = false;
    }
}

public 
OnMapStart()
{
    
PrecacheModel(HHH);
    
PrecacheSound(SPAWN);
    
PrecacheSound(DEATH);
    
PrecacheSound(DOOM1true);
    
PrecacheSound(DOOM2true);
    
PrecacheSound(DOOM3true);
    
PrecacheSound(DOOM4true);

    
PrecacheSound(HELLFIREtrue);
    
PrecacheSound(HELLFIRE2true);
    
    
PrecacheSound(BOMBtrue);
    
PrecacheSound(BOMB2true);    
    
PrecacheSound(BOMB3true);    
    
PrecacheSound(BOMB4true);    
    
    
PrecacheSound(LOLtrue);
    
PrecacheSound(LOL2true);
}

public 
EventInventoryApplication(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
client GetClientOfUserId(GetEventInt(event"userid"));
    if(
g_bIsHHH[client])
    {
        
RemoveModel(client);
        
        
TF2Attrib_RemoveAll(client);
        
        new 
weapon GetPlayerWeaponSlot(client2); 
        
TF2Attrib_RemoveAll(weapon);
        
        
SetVariantInt(0);
        
AcceptEntityInput(client"SetForcedTauntCam");
        
TF2Attrib_RemoveAll(client);
        
SetWearableAlpha(client255);            
        
        
g_bIsHHH[client] = false;
    }
}

public 
Event_Death(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
client GetClientOfUserId(GetEventInt(event"userid"));
    new 
deathflags GetEventInt(event"death_flags");
    if (!(
deathflags TF_DEATHFLAG_DEADRINGER))
    {
        if (
IsValidClient(client) && g_bIsHHH[client])
        {
            
TF2Attrib_RemoveAll(client);
            new 
weapon GetPlayerWeaponSlot(client2); 
            
TF2Attrib_RemoveAll(weapon);            
            
SetWearableAlpha(client255);                
            
EmitSoundToAll(DEATH);
            
SetVariantInt(0);
            
AcceptEntityInput(client"SetForcedTauntCam");
            
g_bIsHHH[client] = false;    
            
RemoveModel(client);            
        }
    }
}

public 
Action:SetModel(client, const String:model[])
{
    if (
IsValidClient(client) && IsPlayerAlive(client))
    {
        
RemoveModel(client);
        
        
SetVariantString(model);
        
AcceptEntityInput(client"SetCustomModel");

        
SetEntProp(clientProp_Send"m_bUseClassAnimations"1);
        
SetWearableAlpha(client0);
        
forceSpellbook(client);
        
SetSpell2(client0500);        
        
Command_getms1(client);
    }
}

public 
Action:RemoveModel(client)
{
    if (
IsValidClient(client))
    {
        new 
weapon GetPlayerWeaponSlot(client2); 
        
        
TF2Attrib_RemoveAll(weapon);
        
SetEntPropFloat(clientProp_Send"m_flModelScale"1.0);
        
UpdatePlayerHitbox(client2.0);

        
SetSpell2(client00);

        
SetVariantString("");
        
AcceptEntityInput(client"SetCustomModel");
        
SetWearableAlpha(client255);
        
Command_getms3(client);
    }
}

public 
Action:Command_wizard(clientargs)
{
    
decl String:arg1[32];
    if (
args 1)
    {
        
arg1 "@me";
    }
    else 
GetCmdArg(1arg1sizeof(arg1));
    new 
String:target_name[MAX_TARGET_LENGTH];
    new 
target_list[MAXPLAYERS], target_count;
    new 
bool:tn_is_ml;

    if ((
target_count ProcessTargetString(
                    
arg1,
                    
client,
                    
target_list,
                    
MAXPLAYERS,
                    
COMMAND_FILTER_ALIVE|(args COMMAND_FILTER_NO_IMMUNITY 0),
                    
target_name,
                    
sizeof(target_name),
                    
tn_is_ml)) <= 0)
    {
        
ReplyToTargetError(clienttarget_count);
        return 
Plugin_Handled;
    }
    for (new 
0target_counti++)
    {
        
Makewizard(target_list[i]);    
        
LogAction(clienttarget_list[i], "\"%L\" made \"%L\" a Giant Wizard!"clienttarget_list[i]);
    }
    
EmitSoundToAll(SPAWN);
    return 
Plugin_Handled;
}

Makewizard(client)
{
    
TF2_SetPlayerClass(clientTFClass_Sniper);
    
TF2_RegeneratePlayer(client);

    new 
ragdoll GetEntPropEnt(clientProp_Send"m_hRagdoll");
    if (
ragdoll MaxClients && IsValidEntity(ragdoll)) AcceptEntityInput(ragdoll"Kill");
    
decl String:weaponname[32];
    
GetClientWeapon(clientweaponnamesizeof(weaponname));
    if (
strcmp(weaponname"tf_weapon_"false) == 0
    {
        
SetEntProp(GetPlayerWeaponSlot(client0), Prop_Send"m_iWeaponState"0);
        
TF2_RemoveCondition(clientTFCond_Slowed);
    }
    
CreateTimer(0.0Timer_Switchclient);
    
SetModel(clientHHH);

    if (
GetConVarBool(g_hCvarThirdPerson))
    {
        
SetVariantInt(1);
        
AcceptEntityInput(client"SetForcedTauntCam");
    }
    
    
TF2_RemoveWeaponSlot(client1);
    
TF2_RemoveWeaponSlot(client0);
    
TF2Items_GiveWeapon(client3);    
    new 
weapon GetPlayerWeaponSlot(client2);
    
SetEntPropEnt(clientProp_Send"m_hActiveWeapon"weapon);
    
    
TF2_SetHealth(client5000);
    
    
SetEntPropFloat(clientProp_Send"m_flModelScale"1.0);
    
UpdatePlayerHitbox(client2.0);
    
    
TF2_AddCondition(clientTFCond_SpeedBuffAlly0.1);
    
g_bIsHHH[client] = true;
    
PrintToChat(client"Wizard Commands: Use Right-Click to launch players, Use 'H' to cast Fireball spell, Use 'R' to throw bombs.");
}

stock UpdatePlayerHitbox(const client, const Float:fScale)
{
    static const 
Float:vecTF2PlayerMin[3] = { -24.5, -24.50.0 }, Float:vecTF2PlayerMax[3] = { 24.5,  24.583.0 };
    
    
decl Float:vecScaledPlayerMin[3], Float:vecScaledPlayerMax[3];

    
vecScaledPlayerMin vecTF2PlayerMin;
    
vecScaledPlayerMax vecTF2PlayerMax;
    
    
ScaleVector(vecScaledPlayerMinfScale);
    
ScaleVector(vecScaledPlayerMaxfScale);
    
    
SetEntPropVector(clientProp_Send"m_vecSpecifiedSurroundingMins"vecScaledPlayerMin);
    
SetEntPropVector(clientProp_Send"m_vecSpecifiedSurroundingMaxs"vecScaledPlayerMax);
}

stock TF2_SetHealth(clientNewHealth)
{
    
SetEntProp(clientProp_Send"m_iHealth"NewHealth1);
    
SetEntProp(clientProp_Data"m_iHealth"NewHealth1);
}

public 
Action:Timer_Switch(Handle:timerany:client)
{
    if (
IsValidClient(client))
    
Givewizard(client);
}

stock Givewizard(client)
{
    
TF2Attrib_RemoveAll(client);
    
    
TF2Attrib_SetByName(client"max health additive bonus"4875.0);
    
TF2Attrib_SetByName(client"health from packs decreased"0.001);
    
TF2Attrib_SetByName(client"major move speed bonus"100.0);
    
TF2Attrib_SetByName(client"cancel falling damage"1.0);            
    
TF2Attrib_SetByName(client"dmg taken from blast reduced"0.5);
    
TF2Attrib_SetByName(client"dmg taken from fire reduced"0.5);
    
TF2Attrib_SetByName(client"dmg taken from bullets reduced"0.5);
    
TF2Attrib_SetByName(client"dmg taken from crit reduced"0.5);
    
TF2Attrib_SetByName(client"dmg from ranged reduced"0.5);
    
TF2Attrib_SetByName(client"SET BONUS: dmg from sentry reduced"0.5);    
    
TF2Attrib_SetByName(client"damage force reduction"0.5);                
    
TF2Attrib_SetByName(client"major increased jump height"2.0);
    
TF2Attrib_SetByName(client"parachute attribute"1.0);
    
TF2Attrib_SetByName(client"cannot be backstabbed"1.0);
    
TF2Attrib_SetByName(client"increased air control"20.0);    
    
TF2Attrib_SetByName(client"airblast vulnerability multiplier"0.0);
    
TF2Attrib_SetByName(client"airblast vertical vulnerability multiplier"0.0);


    new 
Weapon3 GetPlayerWeaponSlot(client2); 
    
TF2Attrib_SetByName(Weapon3"melee attack rate bonus"0.3);    
    
TF2Attrib_SetByName(Weapon3"melee bounds multiplier"3.0);                    
    
TF2Attrib_SetByName(Weapon3"melee range multiplier"3.0);
    
TF2Attrib_SetByName(Weapon3"damage bonus"5.0);
    
TF2Attrib_SetByName(Weapon3"turn to gold"1.0);
    
    
TF2_RemoveAllWearables(client);
}

stock TF2_GetNameOfClass(TFClassType:class, String:name[], maxlen)
{
    switch (class)
    {
    case 
TFClass_ScoutFormat(namemaxlen"scout");
    case 
TFClass_SoldierFormat(namemaxlen"soldier");
    case 
TFClass_PyroFormat(namemaxlen"pyro");
    case 
TFClass_DemoManFormat(namemaxlen"demoman");
    case 
TFClass_HeavyFormat(namemaxlen"heavy");
    case 
TFClass_EngineerFormat(namemaxlen"engineer");
    case 
TFClass_MedicFormat(namemaxlen"medic");
    case 
TFClass_SniperFormat(namemaxlen"sniper");
    case 
TFClass_SpyFormat(namemaxlen"spy");
    }
}

public 
Action:OnPlayerRunCmd(client, &buttons, &impulseFloat:vel[3], Float:angles[3], &weapon)
{
    if (
GetEntityFlags(client) & FL_ONGROUND && g_bIsHHH[client] == true)
    {
        if (
buttons IN_ATTACK2 && g_bIsHHH[client] == true && IsTaunting[client] != true && g_bIsHHH[client] == true)
        { 
            
TF2_StunPlayer(clientFloat:3.0Float:1.0TF_STUNFLAGS_LOSERSTATE);
            
MakePlayerInvisible(client0);
            
            new 
Model CreateEntityByName("prop_dynamic");
            if (
IsValidEdict(Model))
            {
                
IsTaunting[client] = true;
                new 
Float:pos[3], Float:ang[3];
                
decl String:ClientModel[256];
                
                
GetClientModel(clientClientModelsizeof(ClientModel));
                
GetEntPropVector(clientProp_Send"m_vecOrigin"pos);
                
TeleportEntity(ModelposNULL_VECTORNULL_VECTOR);
                
GetClientEyeAngles(clientang);
                
ang[0] = 0.0;
                
ang[2] = 0.0;

                
DispatchKeyValue(Model"model"ClientModel);
                
DispatchKeyValue(Model"DefaultAnim""zap_attack");    
                
DispatchKeyValueVector(Model"angles"ang);
                
                
DispatchSpawn(Model);
                
                
SetVariantString("OnAnimationDone !self:KillHierarchy::0.0:1");
                
AcceptEntityInput(Model"AddOutput");
                
                
CreateTimer(Float:1.0DoHellfireclient);
                
SetEntityMoveType(clientMOVETYPE_NONE);
                
PlayHellfire();
                
                
CreateTimer(Float:2.8ResetTauntclient);
                
SetWeaponsAlpha(client0);                
            }
        }
        else if(
buttons IN_RELOAD && IsTaunting[client] != true && g_bIsHHH[client] == true)        
        {
            
MakePlayerInvisible(client0);

            
SetVariantInt(1);
            
AcceptEntityInput(client"SetForcedTauntCam");
            
            new 
Model CreateEntityByName("prop_dynamic");
            if (
IsValidEdict(Model))
            {
                
IsTaunting[client] = true;
                new 
Float:posc[3], Float:ang[3];
                
decl String:ClientModel[256];
                
                
GetClientModel(clientClientModelsizeof(ClientModel));
                
GetEntPropVector(clientProp_Send"m_vecOrigin"posc);
                
TeleportEntity(ModelposcNULL_VECTORNULL_VECTOR);
                
GetClientEyeAngles(clientang);
                
ang[0] = 0.0;
                
ang[2] = 0.0;

                
DispatchKeyValue(Model"model"ClientModel);
                
DispatchKeyValue(Model"DefaultAnim""bomb_attack");    
                
DispatchKeyValueVector(Model"angles"ang);
                
                
DispatchSpawn(Model);
                
                
SetVariantString("OnAnimationDone !self:KillHierarchy::0.0:1");
                
AcceptEntityInput(Model"AddOutput");
                
                
SetEntityMoveType(clientMOVETYPE_NONE);
                
Playbombsound();
                
CreateTimer(Float:3.0StartBombAttackclient);
                
SetWeaponsAlpha(client0);
            }
        }
    }
    return 
Plugin_Continue;
}

public 
Action:ResetTaunt(Handle:timerany:client)
{
    
IsTaunting[client] = false;
    
MakePlayerInvisible(client255);
    
SetEntityMoveType(clientMOVETYPE_ISOMETRIC);    

}

stock MakePlayerInvisible(clientalpha)
{
    
SetWeaponsAlpha(clientalpha);
    
SetWearableAlpha(clientalpha);
    
SetEntityRenderMode(clientRENDER_TRANSCOLOR);
    
SetEntityRenderColor(client255255255alpha);
}

stock SetWeaponsAlpha (clientalpha)
{
    
decl String:classname[64];
//    new m_hMyWeapons = FindSendPropOffs("CBasePlayer", "m_hMyWeapons");
    
new m_hMyWeapons FindSendPropInfo("CBasePlayer""m_hMyWeapons");
    for(new 
0weapon189+= 4)
    {
        
weapon GetEntDataEnt2(clientm_hMyWeapons i);
        if(
weapon > -&& IsValidEdict(weapon))
        {
            
GetEdictClassname(weaponclassnamesizeof(classname));
            if(
StrContains(classname"tf_weapon"false) != -|| StrContains(classname"tf_wearable"false) != -1)
            {
                
SetEntityRenderMode(weaponRENDER_TRANSCOLOR);
                
SetEntityRenderColor(weapon255255255alpha);
            }
        }
    }
}

public 
Action:DoHellfire(Handle:timerany:client)
{
    new 
Float:vec[3];
    
GetClientEyePosition(clientvec);
    
    
    for(new 
i=1i<=MaxClientsi++)
    {
        if(!
IsClientInGame(i) || !IsPlayerAlive(i)) continue;
        
        new 
Float:pos[3];
        
GetClientEyePosition(ipos);
        
        new 
Float:distance GetVectorDistance(vecpos);
        
        new 
Float:dist 310.0;
        
        
        if(
distance dist)
        {
            if (
== client) continue;
            
            new 
Float:vecc[3];
            
            
vecc[0] = 0.0;
            
vecc[1] = 0.0;
            
vecc[2] = 1500.0;
            
            
TeleportEntity(iNULL_VECTORNULL_VECTORvecc);
            
TF2_IgnitePlayer(iclient);
        }
    }
}

public 
PlayHellfire()
{
    new 
soundswitch;
    
soundswitch GetRandomInt(13);

    
    switch(
soundswitch)
    {
    case 
1:
        {
            
EmitSoundToAll(HELLFIRE);
        }
        
    case 
2:
        {
            
EmitSoundToAll(HELLFIRE2);
        }
        
    case 
3:
        {
            
EmitSoundToAll(HELLFIRE3);
        }
    }
}

stock bool:IsValidClient(client)
{
    if (
client <= 0) return false;
    if (
client MaxClients) return false;
    return 
IsClientInGame(client);
}

stock TF2_RemoveAllWearables(client)
{
    new 
wearable = -1;
    while ((
wearable FindEntityByClassname(wearable"tf_wearable*")) != -1)
    {
        if (
IsValidEntity(wearable))
        {
            new 
player GetEntPropEnt(wearableProp_Send"m_hOwnerEntity");
            if (
client == player)
            {
                
TF2_RemoveWearable(clientwearable);
            }
        }
    }

    while ((
wearable FindEntityByClassname(wearable"tf_powerup_bottle")) != -1)
    {
        if (
IsValidEntity(wearable))
        {
            new 
player GetEntPropEnt(wearableProp_Send"m_hOwnerEntity");
            if (
client == player)
            {
                
TF2_RemoveWearable(clientwearable);
            }
        }
    }

    while ((
wearable FindEntityByClassname(wearable"tf_weapon_spellbook")) != -1)
    {
        if (
IsValidEntity(wearable))
        {
            new 
player GetEntPropEnt(wearableProp_Send"m_hOwnerEntity");
            if (
client == player)
            {
                
TF2_RemoveWearable(clientwearable);
            }
        }
    }
}

stock SetWearableAlpha(clientalphabool:override false)
{
    new 
count;
    for (new 
MaxClients 1<= 2048z++)
    {
        if (!
IsValidEntity(z)) continue;
        
decl String:cls[35];
        
GetEntityClassname(zclssizeof(cls));
        if (!
StrEqual(cls"tf_wearable") && !StrEqual(cls"tf_powerup_bottle")) continue;
        if (
client != GetEntPropEnt(zProp_Send"m_hOwnerEntity")) continue;
        {
            
SetEntityRenderMode(zRENDER_TRANSCOLOR);
            
SetEntityRenderColor(z255255255alpha);
        }
        if (
alpha == 0AcceptEntityInput(z"Kill");
        
count++;
    }
    return 
count;
}

public 
Action:Command_getms1(client)

    new 
soundswitch;
    
soundswitch GetRandomInt(14);    
    switch(
soundswitch)
    {
    case 
1:
        {
            
EmitSoundToAll(DOOM1);
        }
    case 
2:
        {
            
EmitSoundToAll(DOOM2);
        }
    case 
3:
        {
            
EmitSoundToAll(DOOM3);
        }
    case 
4:
        {
            
EmitSoundToAll(DOOM4);
        }
    }
    
ms true;
    
CreateTimer(10.0Command_getms2);    
}

public 
Action:Command_getms2(Handle timer)

    if (
ms == false)
    {
        return 
Plugin_Handled;
    }
    new 
soundswitch2;
    
soundswitch2 GetRandomInt(12);    
    switch(
soundswitch2)
    {
    case 
1:
        {
            
EmitSoundToAll(LOL);
        }
    case 
2:
        {
            
EmitSoundToAll(LOL2);
        }
    }    
    
CreateTimer(10.0Command_GetmsRandom);
    
    return 
Plugin_Handled;
}

public 
Action:Command_getms3(client)

    
ms false;
    return 
Plugin_Handled;
}

public 
Action:Command_getmsnow(clientargs)
{
    
CreateTimer(0.1Command_GetmsRandom);
}

public 
Action:Command_GetmsRandom(Handle timer)
{
    new 
iRand GetRandomInt(1,11);
    if (
iRand == iLastRand)
    {
        
iRand GetRandomInt(1,11);    
    }
    if (
iRand == iLastRand)
    {
        
iRand GetRandomInt(1,11);    
    }    
    switch(
iRand)
    {
    case 
1:
        {
            
EmitSoundToAll(HELLFIRE);
        }
    case 
2:
        {
            
EmitSoundToAll(HELLFIRE2);            
        }
    case 
3:
        {
            
EmitSoundToAll(BOMB);                
        }
    case 
4:
        {
            
EmitSoundToAll(BOMB2);                
        }
    case 
5:
        {
            
EmitSoundToAll(DOOM1);            
        }
    case 
6:
        {
            
EmitSoundToAll(DOOM2);                
        }
    case 
7:
        {
            
EmitSoundToAll(DOOM3);                
        }
    case 
8:
        {
            
EmitSoundToAll(DOOM4);                
        }
    case 
9:
        {
            
EmitSoundToAll(LOL);            
        }
    case 
10:
        {
            
EmitSoundToAll(LOL2);            
        }
    case 
11:
        {
            
EmitSoundToAll(LOL);        
        }            
    }
    
iLastRand iRand;

    
CreateTimer(10.0Command_getms2);
    
    return 
Plugin_Handled;
}

stock forceSpellbook(client)
{
    new 
Handle:hWeapon TF2Items_CreateItem(OVERRIDE_ALL|FORCE_GENERATION);
    
TF2Items_SetClassname(hWeapon"tf_weapon_spellbook");
    
TF2Items_SetItemIndex(hWeapon1070);
    
TF2Items_SetLevel(hWeapon100);
    
TF2Items_SetQuality(hWeapon6);
    
TF2Items_SetNumAttributes(hWeapon1);
    
TF2Items_SetAttribute(hWeapon05470.5);

    new 
entity TF2Items_GiveNamedItem(clienthWeapon);
    
CloseHandle(hWeapon);
    
EquipPlayerWeapon(cliententity);
    return 
entity;
}

SetSpell2(clientspelluses)
{
    new 
ent GetSpellBook(client);
    if(!
IsValidEntity(ent)) return;
    
SetEntProp(entProp_Send"m_iSelectedSpellIndex"spell);
    
SetEntProp(entProp_Send"m_iSpellCharges"uses);
}  

GetSpellBook(client)
{
    new 
entity = -1;
    while((
entity FindEntityByClassname(entity"tf_weapon_spellbook")) != INVALID_ENT_REFERENCE)
    {
        if(
GetEntPropEnt(entityProp_Send"m_hOwnerEntity") == client) return entity;
    }
    return -
1;
}

public 
Playbombsound()
{
    new 
soundswitch;
    
soundswitch GetRandomInt(14);    
    switch(
soundswitch)
    {
    case 
1:
        {
            
EmitSoundToAll(BOMB);
        }
    case 
2:
        {
            
EmitSoundToAll(BOMB2);
        }
    case 
3:
        {
            
EmitSoundToAll(BOMB3);
        }
    case 
4:
        {
            
EmitSoundToAll(BOMB4);
        }
    }
}

public 
Action:StartBombAttack(Handle:timerany:client)
{
    new 
Handle:BTime CreateTimer(Float:2.0CreateBombclientTIMER_REPEAT);
    
CreateTimer(Float:11.75ResetTauntclient);
    
CreateTimer(Float:11.0KillBombsBTime);
    
TimedParticle(client"merasmus_book_attack"Float:11.0);
}
public 
Action:CreateBomb(Handle:timerany:client)
{
    if(
g_bIsHHH[client] == true)
    {
        
SpawnClusters(client);
    }
}
public 
Action:KillBombs(Handle:timerany:Btimer)
{
    
KillTimer(Btimer);
}

public 
SpawnClusters(ent)
{
    if (
IsValidEntity(ent))
    {
        new 
Float:bombSpreadVel 50.0;
        new 
Float:bombVertVel 90.0;
        new 
bombVariation 2;
        
        new 
Float:pos[3];
        
GetClientEyePosition(entpos);
        
pos[2] += 105.0;
        
        
decl Float:ang[3];
        
        for (new 
011i++)
        {
            
ang[0] = ((GetURandomFloat() + 0.1) * bombSpreadVel bombSpreadVel 2.0) * ((GetURandomFloat() + 0.1) * bombVariation);
            
ang[1] = ((GetURandomFloat() + 0.1) * bombSpreadVel bombSpreadVel 2.0) * ((GetURandomFloat() + 0.1) * bombVariation);
            
ang[2] = ((GetURandomFloat() + 0.1) * bombVertVel) * ((GetURandomFloat() + 0.1) * bombVariation);

            new 
ent2 CreateEntityByName("prop_physics_override");

            if(
ent2 != -1)
            {                    
                
DispatchKeyValue(ent2"model"BOMBMODEL);
                
DispatchKeyValue(ent2"solid""6");
                
DispatchKeyValue(ent2"renderfx""0");
                
DispatchKeyValue(ent2"rendercolor""255 255 255");
                
DispatchKeyValue(ent2"renderamt""255");
                
SetEntPropEnt(ent2Prop_Data"m_hOwnerEntity"ent);
                
DispatchSpawn(ent2);
                
TeleportEntity(ent2posNULL_VECTORang);

                
CreateTimer((GetURandomFloat() + 0.1) / 1.75 0.5ExplodeBombletent2TIMER_FLAG_NO_MAPCHANGE);
            }            
        }
    }
}
public 
Action:ExplodeBomblet(Handle:timerany:ent)
{
    if (
IsValidEntity(ent))
    {
        
decl Float:pos[3];
        
GetEntPropVector(entProp_Data"m_vecOrigin"pos);
        
pos[2] += 32.0;

        new 
client GetEntPropEnt(entProp_Data"m_hOwnerEntity");
        new 
team GetEntProp(clientProp_Send"m_iTeamNum");

        
AcceptEntityInput(ent"Kill");
        new 
BombMagnitude 120;
        new 
explosion CreateEntityByName("env_explosion");
        if (
explosion != -1)
        {
            
decl String:tMag[8];
            
IntToString(BombMagnitudetMagsizeof(tMag));
            
DispatchKeyValue(explosion"iMagnitude"tMag);
            
DispatchKeyValue(explosion"spawnflags""0");
            
DispatchKeyValue(explosion"rendermode""5");
            
SetEntProp(explosionProp_Send"m_iTeamNum"team);
            
SetEntPropEnt(explosionProp_Data"m_hOwnerEntity"client);
            
DispatchSpawn(explosion);
            
ActivateEntity(explosion);

            
TeleportEntity(explosionposNULL_VECTORNULL_VECTOR);                
            
AcceptEntityInput(explosion"Explode");
            
AcceptEntityInput(explosion"Kill");
        }        
    }
}
public 
TimedParticle(client, const String:path[32], Float:FTime)
{
    new 
TParticle CreateEntityByName("info_particle_system");
    if (
IsValidEdict(TParticle))
    {
        new 
Float:pos[3];
        
GetEntPropVector(clientProp_Send"m_vecOrigin"pos);
        
        
TeleportEntity(TParticleposNULL_VECTORNULL_VECTOR);
        
        
DispatchKeyValue(TParticle"effect_name"path);
        
        
DispatchKeyValue(TParticle"targetname""particle");
        
        
SetVariantString("!activator");
        
AcceptEntityInput(TParticle"SetParent"clientTParticle0);
        
        
DispatchSpawn(TParticle);
        
ActivateEntity(TParticle);
        
AcceptEntityInput(TParticle"Start");
        
CreateTimer(FTimeKillTParticleTParticle);
        
    }
}
public 
Action:KillTParticle(Handle:timerany:index)
{
    if (
IsValidEntity(index))
    {
        
AcceptEntityInput(index"Kill");
    }

Gray team code:
PHP Code:
#include <sourcemod>
#include <sdkhooks>
#include <sdktools>
#include <tf2>
#include <tf2_stocks>

new bool:isGray[MAXPLAYERS+1] = false;
new 
lastTeam[MAXPLAYERS+1] = 0;

#define PLUGIN_VERSION "0.2"

public Plugin:myinfo =
{
    
name "Gray Team",
    
author "Dachtone",
    
description "Changes player's team to gray",
    
version PLUGIN_VERSION,
    
url "http://sourcegames.ru/"
}

public 
OnPluginStart()
{
    
CreateConVar("gray_version"PLUGIN_VERSION"Gray Team Version"FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);

    
RegAdminCmd("sm_gray"AdmGrayADMFLAG_SLAY"Change player's team to gray");
    
    
HookEvent("player_spawn"PlayerSpawn);
    
HookEvent("player_death"PlayerDeathEventHookMode_Pre);
    
    
HookEvent("arena_round_start"RoundStart);
    
HookEvent("teamplay_round_start"PreRoundStart);
    
    
LoadTranslations("common.phrases");
}

public 
OnClientPostAdminCheck(client)
{
    
isGray[client] = false;
}

public 
OnClientDisconnect(client)
{
    
isGray[client] = false;
}

public 
Action:PlayerDeath(Handle:eventString:name[], bool:dontBroadcast)
{
    new 
client GetClientOfUserId(GetEventInt(event"userid"0));
    if (
IsValidClient(client) && isGray[client])
    {
        
ChangeClientTeam(clientlastTeam[client]);
        
isGray[client] = false;
    }
}

public 
Action:PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
client GetClientOfUserId(GetEventInt(event"userid"));
    
isGray[client] = false;
}

public 
PreRoundStart(Handle:event, const String:name[], bool:dontBroadcast)
{
    for (new 
1<= 32i++)
    {
        if (
IsValidClient(i) && isGray[i])
        {
            
ChangeClientTeam(ilastTeam[i]);
            
TF2_RespawnPlayer(i);
            
isGray[i] = false;
        }
    }
}

public 
RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
{
    for (new 
1<= 32i++)
    {
        if (
IsValidClient(i) && isGray[i])
        {
            
ChangeClientTeam(ilastTeam[i]);
            
TF2_RespawnPlayer(i);
            
isGray[i] = false;
        }
    }
}

public 
Action:AdmGray(clientargs)
{
    if (!
IsValidClient(client))
        return 
Plugin_Handled;
    
    new 
target;
    if (
args 1)
    {
        
target client;
    }
    else
    {
        new 
String:arg[32];
        
GetCmdArg(1argsizeof(arg));
        
target FindTarget(clientarg);
        if (
target == -1)
            return 
Plugin_Handled;
    }
    if (
IsValidClient(target))
    {
        if (!
isGray[target])
        {
            if (
IsPlayerAlive(target))
            {
                
lastTeam[target] = GetClientTeam(target);
                new 
Float:origin[3], Float:angles[3];
                
GetClientAbsOrigin(targetorigin);
                
GetClientAbsAngles(targetangles);
                
ChangeClientTeam(target0);
                
TF2_RespawnPlayer(target);
                
TeleportEntity(targetoriginanglesNULL_VECTOR);
                
isGray[target] = true;
                
                
PrintToChat(client"[SM] %N is in the Gray team now"target);
            }
            else
            {
                
ReplyToCommand(client"[SM] Player must be alive");
            }
        }
        else
        {
            if (
IsPlayerAlive(target))
            {
                new 
Float:origin[3], Float:angles[3];
                
GetClientAbsOrigin(targetorigin);
                
GetClientAbsAngles(targetangles);
                
ChangeClientTeam(targetlastTeam[target]);
                
TF2_RespawnPlayer(target);
                
TeleportEntity(targetoriginanglesNULL_VECTOR);
                
isGray[target] = false;
            }
            else
            {
                
ChangeClientTeam(targetlastTeam[target]);
                
isGray[target] = false;
            }
            
PrintToChat(client"[SM] %N is no longer in the Gray team"target);
        }
    }
    else
    {
        
ReplyToCommand(client"[SM] Player must be available");
    }
    return 
Plugin_Handled;
}

stock bool:IsValidClient(client)
{
    if(
client<=|| client>MaxClients)
    {
        return 
false;
    }

    if(!
IsClientConnected(client) || !IsClientInGame(client))
    {
        return 
false;
    }
    return 
true;

Any help would be appreciated.
PC Gamer 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 16:43.


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