Raised This Month: $ Target: $400
 0% 

[TF2] Set Class All to Specified One


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
7106
Senior Member
Join Date: Jun 2013
Old 05-01-2014 , 04:51   [TF2] Set Class All to Specified One
Reply With Quote #1

first, sry 4 my bad english
set class plugins
https://forums.alliedmods.net/showthread.php?p=1333506
when arena round starts, set class all to specified one by chance (make cvar like sm_setclass_round_chance min 0.00 max 1.00 (percent))
specified one class set by random
please, help me!
7106 is offline
Oshizu
Veteran Member
Join Date: Nov 2012
Location: Warsaw
Old 05-01-2014 , 05:21   Re: [TF2] Set Class All to Specified One
Reply With Quote #2

PHP Code:
#include <tf2_stocks>

new Handle:cvar_classchance
new Float:Class_chance 0.0

public OnPluginStart()
{
    
cvar_classchance CreateConVar("sm_setclass_round_chance""0.10""- Chance To Players Turn into HHH on round start"0true0.01true1.00)  
    
Class_chance 0.10
    HookConVarChange
(cvar_classchanceClassChance_Changed)
    
    
HookEvent("arena_round_start"RoundStartEventHookMode_Pre)
}

public 
Action:RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
Float:random GetRandomFloat(0.011.00)
    if(
random <= Class_chance)
    {
        new class = 
GetRandomInt(19)
        for(new 
1<= MaxClientsi++)
        {
            if(
IsClientInGame(i) && IsPlayerAlive(i))
            {
                if(class == 
1)
                {
                    
TF2_SetPlayerClass(iTFClass_Scout);
                }
                else if(class == 
2)
                {
                    
TF2_SetPlayerClass(iTFClass_Soldier);
                }
                else if(class == 
3)
                {
                    
TF2_SetPlayerClass(iTFClass_Pyro);
                }
                else if(class == 
4)
                {
                    
TF2_SetPlayerClass(iTFClass_DemoMan);
                }
                else if(class == 
5)
                {
                    
TF2_SetPlayerClass(iTFClass_Heavy);
                }
                else if(class == 
6)
                {
                    
TF2_SetPlayerClass(iTFClass_Engineer);
                }
                else if(class == 
7)
                {
                    
TF2_SetPlayerClass(iTFClass_Medic);
                }
                else if(class == 
8)
                {
                    
TF2_SetPlayerClass(iTFClass_Sniper);
                }
                else if(class == 
9)
                {
                    
TF2_SetPlayerClass(iTFClass_Spy);
                }
            }
        }
    }
}

public 
ClassChance_Changed(Handle:cvar, const String:oldVal[], const String:newVal[])
{
    new 
Float:value StringToFloat(newVal)
    
Class_chance value

__________________
...
Oshizu is offline
7106
Senior Member
Join Date: Jun 2013
Old 05-01-2014 , 05:37   Re: [TF2] Set Class All to Specified One
Reply With Quote #3

there's big problem!
players' weapons do not changed!!!
please, help me!
7106 is offline
Oshizu
Veteran Member
Join Date: Nov 2012
Location: Warsaw
Old 05-01-2014 , 06:00   Re: [TF2] Set Class All to Specified One
Reply With Quote #4

PHP Code:
___ 
__________________
...

Last edited by Oshizu; 05-01-2014 at 10:11.
Oshizu is offline
7106
Senior Member
Join Date: Jun 2013
Old 05-01-2014 , 06:12   Re: [TF2] Set Class All to Specified One
Reply With Quote #5

same problem!
refer this plugin https://forums.alliedmods.net/showthread.php?p=1333506
and please, help me!
7106 is offline
Oshizu
Veteran Member
Join Date: Nov 2012
Location: Warsaw
Old 05-01-2014 , 10:09   Re: [TF2] Set Class All to Specified One
Reply With Quote #6

Try this one maybe:
PHP Code:
#include <tf2_stocks>

new Handle:cvar_classchance
new Float:Class_chance 0.0

public OnPluginStart()
{
    
cvar_classchance CreateConVar("sm_setclass_round_chance""0.10""- Chance To Players Turn into HHH on round start"0true0.01true1.00)  
    
Class_chance 0.10
    HookConVarChange
(cvar_classchanceClassChance_Changed)
    
    
HookEvent("arena_round_start"RoundStartEventHookMode_Pre)
}

public 
Action:RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
Float:random GetRandomFloat(0.011.00)
    if(
random <= Class_chance)
    {
        new class = 
GetRandomInt(19)
        for(new 
1<= MaxClientsi++)
        {
            if(
IsClientInGame(i) && IsPlayerAlive(i))
            {
                if(class == 
1)
                {
                    
TF2_SetPlayerClass(iTFClass_Scoutfalse);
                }
                else if(class == 
2)
                {
                    
TF2_SetPlayerClass(iTFClass_Soldierfalse);
                }
                else if(class == 
3)
                {
                    
TF2_SetPlayerClass(iTFClass_Pyrofalse);
                }
                else if(class == 
4)
                {
                    
TF2_SetPlayerClass(iTFClass_DemoManfalse);
                }
                else if(class == 
5)
                {
                    
TF2_SetPlayerClass(iTFClass_Heavyfalse);
                }
                else if(class == 
6)
                {
                    
TF2_SetPlayerClass(iTFClass_Engineerfalse);
                }
                else if(class == 
7)
                {
                    
TF2_SetPlayerClass(iTFClass_Medicfalse);
                }
                else if(class == 
8)
                {
                    
TF2_SetPlayerClass(iTFClass_Sniperfalse);
                }
                else if(class == 
9)
                {
                    
TF2_SetPlayerClass(iTFClass_Spyfalse);
                }
                
TF2_RegeneratePlayer(i);
                new 
weapon GetPlayerWeaponSlot(iTFWeaponSlot_Primary);
                if(
IsValidEntity(weapon))
                {
                        
SetEntPropEnt(iProp_Send"m_hActiveWeapon"weapon);
                }
            }
        }
    }
}

public 
ClassChance_Changed(Handle:cvar, const String:oldVal[], const String:newVal[])
{
    new 
Float:value StringToFloat(newVal)
    
Class_chance value

__________________
...

Last edited by Oshizu; 05-01-2014 at 10:10.
Oshizu is offline
GsiX
gee, six eggs
Join Date: Aug 2012
Location: Land Below The Wind
Old 05-01-2014 , 10:37   Re: [TF2] Set Class All to Specified One
Reply With Quote #7

1) Grab the player id on player spawn.
2) Change they class to your desire class (chance).
3) Force respawn them.

It fix my problem with the weapon.

EDIT: The point is respawn them fixed for me.
__________________
If i happen to insulted you unintentionally,
it was me and Google Translate who did it.

Last edited by GsiX; 05-01-2014 at 10:40.
GsiX is offline
friagram
Veteran Member
Join Date: Sep 2012
Location: Silicon Valley
Old 05-01-2014 , 13:58   Re: [TF2] Set Class All to Specified One
Reply With Quote #8

stock TF2_SetPlayerClass(client, TFClassType:class, bool:weapons=true, bool:persistent=true)

I believe you are looking for client class true false, think thats what I do. Using respawn is fail, as class limiter plugins will just kick in and swap them back.
__________________
Profile - Plugins
Add me on steam if you are seeking sp/map/model commissions.

Last edited by friagram; 05-01-2014 at 13:59.
friagram is offline
7106
Senior Member
Join Date: Jun 2013
Old 05-02-2014 , 05:51   Re: [TF2] Set Class All to Specified One
Reply With Quote #9

ありがとうございます
7106 is offline
GsiX
gee, six eggs
Join Date: Aug 2012
Location: Land Below The Wind
Old 05-02-2014 , 06:18   Re: [TF2] Set Class All to Specified One
Reply With Quote #10

Quote:
Originally Posted by friagram View Post
stock TF2_SetPlayerClass(client, TFClassType:class, bool:weapons=true, bool:persistent=true)

I believe you are looking for client class true false, think thats what I do. Using respawn is fail, as class limiter plugins will just kick in and swap them back.
Can you explain more. Perhaps an example?

Quote:
Originally Posted by 7106 View Post
ありがとうございます
I love you too.

EDIT: nvm i figured out.
__________________
If i happen to insulted you unintentionally,
it was me and Google Translate who did it.

Last edited by GsiX; 05-02-2014 at 10:56.
GsiX 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 04:35.


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