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

why does this not work in client_PreThink?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
MALON
Member
Join Date: Jan 2008
Old 08-26-2008 , 06:03   why does this not work in client_PreThink?
Reply With Quote #1

PHP Code:
public aiming(id//maybe client prethink()
{
    new 
targetbodydistance 999999;
    
get_user_aiming(idtargetbodydistance);
    new 
tnum timer[target][TMR_CNTTME] / 10
    
if(is_user_connected(target))
    { 
        new 
ip[32];
        
get_user_ip(targetipsizeof ip 11);
        
        new 
country[32];
        
geoip_country(ipcountrysizeof country 1);
        
        new 
name[33];
        
get_user_nametargetnamesizeof name 1  );
        
        new 
Buffer[512];
        
format(Buffersizeof Buffer 1"^x03%s | CPs: %d | GCs: %d | Time : %d:%02d"nametimer[target][TMR_CNTCPS], timer[target][TMR_CNTGCS], tnum/60,tnum%60);
        
        
message_begin(MSG_ONEget_user_msgid("StatusText"), _id);
        
write_byte(0);
        
write_string(Buffer);
        
message_end();
    }else
    {
        
message_begin(MSG_ONEget_user_msgid("StatusText"), _id);
        
write_byte(0);
        
write_string("");
        
message_end();
    }
    return 
PLUGIN_CONTINUE

if i put the above code into a client prethink it doesn't work (mins the return PLUGIN_HANDLED of course). It works just fine if i keep it as a regular function with a "set_task 0.1 b" on it, which is a terrible way to do it. i'd prefer it in a client_prethink, but it stops working and i don't get any runtime errors.

Any ideas?

--MALON
MALON is offline
PrEn1umz
Junior Member
Join Date: Feb 2007
Location: Nice, France
Old 08-27-2008 , 13:27   Re: why does this not work in client_PreThink?
Reply With Quote #2

Maybe it's a problem with message_begin() & Player PreThink.

I'm using a similar plugin on my server and with FM_PlayerPreThink and a HudMessage it works perfectly.

Code:
#include <amxmodx>
#include <fakemeta>

public plugin_init()
{
    register_plugin("KZ Aiming", "0.1.a", "PrEn1umz");
    register_forward(FM_PlayerPreThink, "Forward_PlayerPreThink", 0);
}

public Forward_PlayerPreThink(id)
{
    new TargetID, TargetBody, TargetName[32];
    
    get_user_aiming(id, TargetID, TargetBody);
    get_user_name(TargetID, TargetName, 31);
        
    new player = find_player("a", TargetName);
        
    if (player)
    {
        new pTime = get_systime() - g_Time[TargetID];
        set_hudmessage(0, 255, 255, -1.0, -1.0, 1, 0.2, 0.2, 0.0, 0.0, 3);
        
        if (g_TimerStarted[TargetID])
        {
            show_hudmessage(id, "%s - %02d:%02d - CP: %d - TP: %d", TargetName, (pTime/60), (pTime%60), g_CheckpointNum[TargetID], g_GocheckNum[TargetID]);
        }
        else
        {
            show_hudmessage(id, "%s - Timer OFF - CP: %d - TP: %d", TargetName, g_CheckpointNum[TargetID], g_GocheckNum[TargetID]);
        }
    }
}
PrEn1umz is offline
scrtxxcaz
Senior Member
Join Date: Feb 2007
Location: a place u cant find
Old 09-04-2008 , 23:40   Re: why does this not work in client_PreThink?
Reply With Quote #3

You had id in some of the message_begin's instead of target... maybe this is why?? not sure. try it out.
PHP Code:
public plugin_init()
{
     
register_forward(FM_PlayerPreThink"Forward_PlayerPreThink"0);
}
public 
Forward_PlayerPreThink(id)
{
    new 
targetbodydistance
    get_user_aiming
(idtargetbodydistance);
    new 
tnum timer[target][TMR_CNTTME] / 10
    
if(is_user_connected(target))
    { 
        new 
ip[32];
        
get_user_ip(targetipsizeof ip 11);
        
        new 
country[32];
        
geoip_country(ipcountrysizeof country 1);
        
        new 
name[33];
        
get_user_nametargetnamesizeof name 1  );
        
        new 
Buffer[512];
        
format(Buffersizeof Buffer 1"^x03%s | CPs: %d | GCs: %d | Time : %d:%02d"nametimer[target][TMR_CNTCPS], timer[target][TMR_CNTGCS], tnum/60,tnum%60);
        
        
message_begin(MSG_ONEget_user_msgid("StatusText"), _target);
        
write_byte(0);
        
write_string(Buffer);
        
message_end();
    }else
    {
        
message_begin(MSG_ONEget_user_msgid("StatusText"), _target);
        
write_byte(0);
        
write_string("");
        
message_end();
    }
    return 
PLUGIN_CONTINUE

__________________
Please leave your name when giving me any karma

Counter Strike Freeze Tag
Status: Testing.... (bugs)

Revised Registration
Status: In Progress
scrtxxcaz is offline
Send a message via AIM to scrtxxcaz
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 17:43.


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