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

Solved [CSGO] Force players to first-person on spawn.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
AuricYoutube
Senior Member
Join Date: Aug 2016
Location: Here
Old 01-06-2022 , 07:15   [CSGO] Force players to first-person on spawn.
Reply With Quote #1

I need a plugin that simply forces players to firstperson when they spawn in when the plugin is loaded. Help would be greatly appreciated.

Last edited by AuricYoutube; 01-07-2022 at 05:09.
AuricYoutube is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 01-06-2022 , 10:35   Re: [CSGO] Force players to first-person on spawn.
Reply With Quote #2

PHP Code:
public void OnPluginStart()
{
    
HookEvent("player_spawn"player_spawn);
}


public 
void player_spawn(Event event, const char[] namebool dontBroadcast)
{
    
int userid event.GetInt("userid");
    
int client GetClientOfUserId(userid);

    if(
IsClientSourceTV(client) || IsClientReplay(client) ||
        
GetEntProp(clientProp_Send"m_iPlayerState") != 0)
    {
        return;
    }

    
CreateTimer(0.0delayuseridTIMER_FLAG_NO_MAPCHANGE);
}

public 
Action delay(Handle timerany data)
{
    
int client GetClientOfUserId(data);

    if(
client)
    {
        
ClientCommand(client"firstperson");
    }

__________________
Do not Private Message @me
Bacardi is offline
AuricYoutube
Senior Member
Join Date: Aug 2016
Location: Here
Old 01-07-2022 , 05:09   Re: [CSGO] Force players to first-person on spawn.
Reply With Quote #3

Quote:
Originally Posted by Bacardi View Post
PHP Code:
public void OnPluginStart()
{
    
HookEvent("player_spawn"player_spawn);
}


public 
void player_spawn(Event event, const char[] namebool dontBroadcast)
{
    
int userid event.GetInt("userid");
    
int client GetClientOfUserId(userid);

    if(
IsClientSourceTV(client) || IsClientReplay(client) ||
        
GetEntProp(clientProp_Send"m_iPlayerState") != 0)
    {
        return;
    }

    
CreateTimer(0.0delayuseridTIMER_FLAG_NO_MAPCHANGE);
}

public 
Action delay(Handle timerany data)
{
    
int client GetClientOfUserId(data);

    if(
client)
    {
        
ClientCommand(client"firstperson");
    }

Works perfectly. Thank you very much Bacardi!
AuricYoutube is offline
FroGeX
Senior Member
Join Date: Aug 2020
Old 01-07-2022 , 18:57   Re: [CSGO] Force players to first-person on spawn.
Reply With Quote #4

what mean m_iPlayerState?
FroGeX is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 01-07-2022 , 20:35   Re: [CSGO] Force players to first-person on spawn.
Reply With Quote #5

Quote:
Originally Posted by FroGeX View Post
what mean m_iPlayerState?
Player different state when enter in game and during game.
But keep in mind, these values maybe not up to date.
PHP Code:
// The various states the player can be in during the join game process.
enum CSPlayerState
{
    
// Happily running around in the game.
    // You can't move though if CSGameRules()->IsFreezePeriod() returns true.
    // This state can jump to a bunch of other states like STATE_PICKINGCLASS or STATE_DEATH_ANIM.
    
STATE_ACTIVE=0,
    
    
// This is the state you're in when you first enter the server.
    // It's switching between intro cameras every few seconds, and there's a level info 
    // screen up.
    
STATE_WELCOME,            // Show the level intro screen.
    
    // During these states, you can either be a new player waiting to join, or
    // you can be a live player in the game who wants to change teams.
    // Either way, you can't move while choosing team or class (or while any menu is up).
    
STATE_PICKINGTEAM,            // Choosing team.
    
STATE_PICKINGCLASS,            // Choosing class.
    
    
STATE_DEATH_ANIM,            // Playing death anim, waiting for that to finish.
    
STATE_DEATH_WAIT_FOR_KEY,    // Done playing death anim. Waiting for keypress to go into observer mode.
    
STATE_OBSERVER_MODE,        // Noclipping around, watching players, etc.

    
STATE_GUNGAME_RESPAWN,        // Respawning the player in a gun game
    
STATE_DORMANT,                // No thinking, client updates, etc

    
NUM_PLAYER_STATES
}; 
__________________
Do not Private Message @me
Bacardi 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 19:40.


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