Raised This Month: $32 Target: $400
 8% 

A problem with invisible weapons "No user logon" error.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
4LiveTV
Junior Member
Join Date: Jan 2016
Old 11-03-2017 , 17:54   A problem with invisible weapons "No user logon" error.
Reply With Quote #1

Sorry for bad english :/
Hi! I just wanted to trun the player's model and his weapon invisible. Player's model is easy to hide but i have a problem with hiding weapons.
I use this for hiding weapons on my serv:
Code:
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>
public Plugin:myinfo = 
{
    name = "InvisFix",
    author = "~",
    description = "",
    version = "1.0",
    url = "<- URL ->"
}
public OnPluginStart()
{
    HookEvent("player_spawn", onPlayerSpawn);
}
public Action:onPlayerSpawn(Handle:event,const String:name[],bool:dontBroadcast)
{
    ServerCommand("ent_fire env_cascade_light kill");
    forceinvis();
    forcevisible();
}
forceinvis()
{
    for(new client = 1; client <= MaxClients; client++)
    {
        if(IsClientInGame(client) && IsValidClient(client))
        {
            SDKHookEx(client, SDKHook_PostThinkPost, OnPostThinkPost);
            SetEntProp(client, Prop_Send, "m_nRenderFX", RENDERFX_NONE);
            SetEntProp(client, Prop_Send, "m_nRenderMode", RENDER_NONE);
        }
    }
    
    
    
    new entity = MaxClients+1;
    
 while( (entity = FindEntityByClassname(entity, "weaponworldmodel")) != -1 )
    {
        if(IsValidEntity(entity))
            SetEntProp(entity, Prop_Send, "m_nModelIndex", 0);
    }
forcevisible()
{
    for(new client = 1; client <= MaxClients; client++)
    {
        if(IsClientInGame(client)  && IsValidClient(client))
        {
            SetEntityRenderMode(client, RENDER_TRANSCOLOR);
            SetEntityRenderColor(client, 255, 255, 255, 255); 
        }
    }
}
public OnPostThinkPost(client)
{
    SetEntProp(client, Prop_Send, "m_iAddonBits", 0);
}  
public IsValidClient( client ) 
{ 
    if ( !( 1 <= client <= MaxClients ) || !IsClientInGame(client) ) 
        return false; 
    
    return true; 
}
I also tryied this
Code:
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>
public Plugin:myinfo = 
{
    name = "InvisFix",
    author = "~",
    description = "",
    version = "1.0",
    url = "<- URL ->"
}
public OnPluginStart()
{
    HookEvent("player_spawn", onPlayerSpawn);
}
public Action:onPlayerSpawn(Handle:event,const String:name[],bool:dontBroadcast)
{
    ServerCommand("ent_fire env_cascade_light kill");
    forceinvis();
    forcevisible();
}
forceinvis()
{
    for(new client = 1; client <= MaxClients; client++)
    {
        if(IsClientInGame(client) && IsValidClient(client))
        {
            SDKHookEx(client, SDKHook_PostThinkPost, OnPostThinkPost);
            SetEntProp(client, Prop_Send, "m_nRenderFX", RENDERFX_NONE);
            SetEntProp(client, Prop_Send, "m_nRenderMode", RENDER_NONE);
        }
    }
    
    
    
    new entity = MaxClients+1;
    
    while( (entity = FindEntityByClassname(entity, "weaponworldmodel")) != -1 )
    {
        SetEntProp(entity, Prop_Send, "m_nModelIndex", 0);
    }
}
forcevisible()
{
    for(new client = 1; client <= MaxClients; client++)
    {
        if(IsClientInGame(client)  && IsValidClient(client))
        {
            SetEntityRenderMode(client, RENDER_TRANSCOLOR);
            SetEntityRenderColor(client, 255, 255, 255, 255); 
        }
    }
}
public OnPostThinkPost(client)
{
    SetEntProp(client, Prop_Send, "m_iAddonBits", 0);
}  
public IsValidClient( client ) 
{ 
    if ( !( 1 <= client <= MaxClients ) || !IsClientInGame(client) ) 
        return false; 
    
    return true; 
}
These plugins works perfectly but almost every minute random players are disconecting form server with "No user logon" reason.

What I made wrong?
4LiveTV is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 11-03-2017 , 19:41   Re: A problem with invisible weapons "No user logon" error.
Reply With Quote #2

...don't sdkhook ALL players everytime when somebody spawn.
You create multiple hooks on players.
__________________
Do not Private Message @me

Last edited by Bacardi; 11-03-2017 at 19:42.
Bacardi is offline
4LiveTV
Junior Member
Join Date: Jan 2016
Old 11-04-2017 , 06:26   Re: A problem with invisible weapons "No user logon" error.
Reply With Quote #3

Can You explain me how to do this?
I'm beginer :p Thanks
Quote:
Originally Posted by Bacardi View Post
...don't sdkhook ALL players everytime when somebody spawn.
You create multiple hooks on players.

Last edited by 4LiveTV; 11-04-2017 at 07:01.
4LiveTV is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 11-04-2017 , 08:35   Re: A problem with invisible weapons "No user logon" error.
Reply With Quote #4

Hook onclientputinserver
__________________
8guawong is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 11-04-2017 , 09:05   Re: A problem with invisible weapons "No user logon" error.
Reply With Quote #5

I try explain, english is unfortunally not my native language.

Spoiler



It would be good if you build own test server in your own computer rather than test on hosted server where are other players playing.

But...

Lets created code what SDKHook players and once.
PHP Code:
/*
 * Hide player weapons from body, this will work all the time.
*/

#include <sdkhooks>

// SM plugin loaded. 
public void OnPluginStart()
{

    
// Loop all players who are currently on server.

    
for(int i 1<= MaxClientsi++)
    {
        
// found player, forward client index to one of callbacks.
        
if(IsClientInGame(i)) OnClientPutInServer(i);
    }
}


// When player joined server
public void OnClientPutInServer(int client)
{
    
// use sdkhook to this player
    
SDKHookEx(clientSDKHook_PostThinkPostPostThinkPost); 
}

// ...this will called as often as server tickrate
public void PostThinkPost(client)
{
    
SetEntProp(clientProp_Send"m_iAddonBits",0); // Hide attached weapons from player body


ok, we don't want this work 24/7.
Lets create admin command for enable and disable this weapon hide by using boolean variable.

Code:
#include <sdkhooks>

// global variable - boolean 1/0
bool my_toggle_onoff;

// SM plugin loaded. 
public void OnPluginStart()
{

	// Loop all players who are currently on server.

	for(int i = 1; i <= MaxClients; i++)
	{
		// found player, forward client index to one of callbacks.
		if(IsClientInGame(i)) OnClientPutInServer(i);
	}

	// Admin command
	RegAdminCmd("sm_test", test, ADMFLAG_GENERIC);
}


// Admin command callback
public Action test(int client, int args)
{
	// Toggle on/off variable
	my_toggle_onoff = !my_toggle_onoff;


	// Print in chat when player in game use admin command.
	if(client != 0) PrintToChat(client, "[SM] You turned this %s", my_toggle_onoff ? "ON":"OFF");

	// Print in server console when command used through server input
	if(client == 0) PrintToServer("[SM] You turned this %s", my_toggle_onoff ? "ON":"OFF");

	return Plugin_Handled;
}


// When player joined server
public void OnClientPutInServer(int client)
{
	// use sdkhook to this player
	SDKHookEx(client, SDKHook_PostThinkPost, PostThinkPost); 
}

// 
public void PostThinkPost(client)
{
	// When variable is false, don't continue code further
	if(!my_toggle_onoff) return;



	SetEntProp(client, Prop_Send, "m_iAddonBits",0); // Hide attached weapons from player body
}



Here rest of code

Code:
#include <sdkhooks>

// global variable - boolean 1/0
bool my_toggle_onoff;

// SM plugin loaded. 
public void OnPluginStart()
{

	// Loop all players who are currently on server.

	for(int i = 1; i <= MaxClients; i++)
	{
		// found player, forward client index to one of callbacks.
		if(IsClientInGame(i)) OnClientPutInServer(i);
	}


	// Admin command
	RegAdminCmd("sm_test", test, ADMFLAG_GENERIC);
}


// Admin command callback
public Action test(int client, int args)
{
	// Toggle on/off variable
	my_toggle_onoff = !my_toggle_onoff;


	// Print in chat when player in game use admin command.
	if(client != 0) PrintToChat(client, "[SM] You turned this %s", my_toggle_onoff ? "ON":"OFF");

	// Print in server console when command used through server input
	if(client == 0) PrintToServer("[SM] You turned this %s", my_toggle_onoff ? "ON":"OFF");

	UpdatePlayers();

	return Plugin_Handled;
}

void UpdatePlayers()
{

	for(int i = 1; i <= MaxClients; i++)
	{
		// skip client index which not have player
		if(!IsClientInGame(i)) continue;

		// Set visibility
		SetEntProp(i, Prop_Send, "m_nRenderMode", my_toggle_onoff ? RENDER_NONE:RENDER_NORMAL);
	}

}

// When player joined server
public void OnClientPutInServer(int client)
{
	// use sdkhook to this player
	SDKHookEx(client, SDKHook_PostThinkPost, PostThinkPost); 

	UpdatePlayers();
}

// 
public void PostThinkPost(client)
{
	// When variable is false, don't continue code further
	if(!my_toggle_onoff) return;



	SetEntProp(client, Prop_Send, "m_iAddonBits",0); // Hide attached weapons from player body
}
__________________
Do not Private Message @me

Last edited by Bacardi; 11-04-2017 at 09:16.
Bacardi is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 11-04-2017 , 09:10   Re: A problem with invisible weapons "No user logon" error.
Reply With Quote #6

btw, if players game still crash or disconnect from server for this...

There could be some kind bug happen.
[CSGO] Client crash when m_iAddonBits used

I haven't occur to this...
__________________
Do not Private Message @me
Bacardi is offline
4LiveTV
Junior Member
Join Date: Jan 2016
Old 11-04-2017 , 10:31   Re: A problem with invisible weapons "No user logon" error.
Reply With Quote #7

Very good work!
But there is a knife still visible. Can you make it invisible?
4LiveTV is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 11-04-2017 , 10:41   Re: A problem with invisible weapons "No user logon" error.
Reply With Quote #8

What game you are using ?
__________________
Do not Private Message @me
Bacardi is offline
supertimor
AlliedModders Donor
Join Date: Sep 2017
Old 11-04-2017 , 11:00   Re: A problem with invisible weapons "No user logon" error.
Reply With Quote #9

Its a CS:GO, so we need to remember about weapon,knife / weapon, bayonet after sh1tty volvo update..
supertimor is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 11-04-2017 , 12:05   Re: A problem with invisible weapons "No user logon" error.
Reply With Quote #10

hm... when they have removed null/world model , doesn't exist anymore.
Now it will crash players game when set modelindex to 0.


Btw, how old your csgo game is ?

Because that example what I gave hide all weapons...
__________________
Do not Private Message @me

Last edited by Bacardi; 11-04-2017 at 12:14.
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:09.


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