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

[Solved] Why is client_PreThink not working?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
SicknessArG
Junior Member
Join Date: Oct 2012
Location: Paraná, Entre Ríos (ARG)
Old 06-27-2015 , 10:07   [Solved] Why is client_PreThink not working?
Reply With Quote #1

I have days with this, I don't know why is not working on my hosted server, but is working on lan.
I have AMX Mod X 1.8.2, Metamod v1.21 Everything default

Code:
public client_PreThink(id) {     if(is_user_alive(id))     {         static iPlayer, osef;         get_user_aiming(id, iPlayer, osef, 2048);                 if(IsPlayer(iPlayer))         {             static szName[32];             get_user_name(iPlayer, szName, charsmax(szName));                         set_hudmessage(64, 64, 255, -1.0, -1.0, 1, 0.1, 0.1, 0.1, 0.1, -1);             show_hudmessage(id, "%s", szName);         }     } }

Last edited by SicknessArG; 06-29-2015 at 14:15.
SicknessArG is offline
Send a message via MSN to SicknessArG Send a message via Skype™ to SicknessArG
Natsheh
Veteran Member
Join Date: Sep 2012
Old 06-27-2015 , 15:20   Re: Why is client_PreThink not working?
Reply With Quote #2

Try using fakemeta way
PHP Code:
public plugin_init()
{
              
register_forward(FM_PlayerPreThink"client_PreThink")
}
public 
client_PreThink(id)
{
    if(
is_user_alive(id)) 
    { 
        static 
iPlayerosef;
        
get_user_aiming(idiPlayerosef2048);
        
        if(
IsPlayer(iPlayer)) 
        { 
            static 
szName[32];
            
get_user_name(iPlayerszNamecharsmax(szName));
            
            
set_hudmessage(6464255, -1.0, -1.010.10.10.10.1, -1);
            
show_hudmessage(id"%s"szName);
        }
    }

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 06-27-2015 , 15:38   Re: Why is client_PreThink not working?
Reply With Quote #3

Quote:
Originally Posted by Natsheh View Post
Try using fakemeta way
PHP Code:
public plugin_init()
{
              
register_forward(FM_PlayerPreThink"client_PreThink")
}
public 
client_PreThink(id)
{
    if(
is_user_alive(id)) 
    { 
        static 
iPlayerosef;
        
get_user_aiming(idiPlayerosef2048);
        
        if(
IsPlayer(iPlayer)) 
        { 
            static 
szName[32];
            
get_user_name(iPlayerszNamecharsmax(szName));
            
            
set_hudmessage(6464255, -1.0, -1.010.10.10.10.1, -1);
            
show_hudmessage(id"%s"szName);
        }
    }

How this will fix the problem ? Both engine and fakemeta use pfnPlayerPreThink game exported function, nothing different.

@SicknessArG, I can't see a problem in your code. Please show us where you defined IsPlayer, maybe it's a problem with it.
You can do some debugging on your own, place messages inside the code so you will know how it works.
__________________
HamletEagle is offline
meTaLiCroSS
Gaze Upon My Hat
Join Date: Feb 2009
Location: Viña del Mar, Chile
Old 06-27-2015 , 17:56   Re: Why is client_PreThink not working?
Reply With Quote #4

Sure about it's not generating any forward call? Have you tested it with a simple print to server console?
__________________
Quote:
Originally Posted by joropito View Post
You're right Metalicross
meTaLiCroSS is offline
SicknessArG
Junior Member
Join Date: Oct 2012
Location: Paraná, Entre Ríos (ARG)
Old 06-27-2015 , 23:53   Re: Why is client_PreThink not working?
Reply With Quote #5

Quote:
Originally Posted by HamletEagle View Post
How this will fix the problem ? Both engine and fakemeta use pfnPlayerPreThink game exported function, nothing different.

@SicknessArG, I can't see a problem in your code. Please show us where you defined IsPlayer, maybe it's a problem with it.
You can do some debugging on your own, place messages inside the code so you will know how it works.
Code:
#define IsPlayer(%1)            (1 <= %1 <= MaxPlayers) // MaxPlayers = get_maxplayers()
Quote:
Originally Posted by meTaLiCroSS View Post
Sure about it's not generating any forward call? Have you tested it with a simple print to server console?
Yes, I made a debug step by step, everything is working except after IsPlayer codindition.
SicknessArG is offline
Send a message via MSN to SicknessArG Send a message via Skype™ to SicknessArG
Bos93
Veteran Member
Join Date: Jul 2010
Old 06-28-2015 , 05:44   Re: Why is client_PreThink not working?
Reply With Quote #6

meta list? engine is loaded?
__________________
Bos93 is offline
Send a message via ICQ to Bos93 Send a message via Skype™ to Bos93
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 06-28-2015 , 06:15   Re: Why is client_PreThink not working?
Reply With Quote #7

Print the value of iPlayer, see if it is a valid index or not. Also, as Bos93 said, check if everything is correctly loaded.
__________________
HamletEagle is offline
meTaLiCroSS
Gaze Upon My Hat
Join Date: Feb 2009
Location: Viña del Mar, Chile
Old 06-28-2015 , 21:36   Re: Why is client_PreThink not working?
Reply With Quote #8

Which OS? If linux, CentOS/Debian?
__________________
Quote:
Originally Posted by joropito View Post
You're right Metalicross
meTaLiCroSS is offline
SicknessArG
Junior Member
Join Date: Oct 2012
Location: Paraná, Entre Ríos (ARG)
Old 06-29-2015 , 14:15   Re: Why is client_PreThink not working?
Reply With Quote #9

Quote:
Originally Posted by Bos93 View Post
meta list? engine is loaded?
Quote:
Originally Posted by HamletEagle View Post
Print the value of iPlayer, see if it is a valid index or not. Also, as Bos93 said, check if everything is correctly loaded.
Quote:
Originally Posted by meTaLiCroSS View Post
Which OS? If linux, CentOS/Debian?
I think it was by the modules, I deleted the ';' in every module in modules.ini and it worked.
My bad.

Thanks for everything.

Last edited by SicknessArG; 06-29-2015 at 14:16.
SicknessArG is offline
Send a message via MSN to SicknessArG Send a message via Skype™ to SicknessArG
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 01:30.


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