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

How to show hud to individual players


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
SID12
Junior Member
Join Date: May 2019
Old 08-20-2019 , 13:04   How to show hud to individual players
Reply With Quote #1

I can't remember how to get the user id in a plugin for example:

set_hudmessage(255, 0, 0, 0.95, 0.01, 0, 0.1, 0.9, 0.1, 0.1, -1)
show_hudmessage(0 , "Time: %s ",time)

This makes part of a plugin that shows time but when you type the command the hud gets activated for everyone because it's set to 0 and I know for a fact that you can use the individual user id's to show it only to the player that types a certain command can someone remind it to me please? thx a lot
SID12 is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 08-20-2019 , 13:12   Re: How to show hud to individual players
Reply With Quote #2

Show the full code, most likely the player id is in the function parameters.
__________________
edon1337 is offline
SID12
Junior Member
Join Date: May 2019
Old 08-20-2019 , 13:18   Re: How to show hud to individual players
Reply With Quote #3

Quote:
Originally Posted by edon1337 View Post
Show the full code, most likely the player id is in the function parameters.
They aren't in the parameters:


public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_clcmd("say /thetime","The_time",0,"Arata ora")
register_clcmd("say_team /thetime","The_time",0,"Arata ora")
register_clcmd("say /timeleft","Timeleft",0,"Arata timpul ramas")
register_clcmd("say_team /timeleft","Timeleft",0,"Arata timpul ramas")
}

public The_time()
{
if(task_exists(1))
remove_task(1)
else
set_task(1.0,"the_time",1,_,_,"b",_)
}

public Timeleft()
{
if(task_exists(2))
remove_task(2)
else
set_task(1.0,"timeleft",2,_,_,"b",_)
}

public the_time()
{
static time[33]
get_time("%H:%M:%S",time,32)
set_hudmessage(255, 0, 0, 0.95, 0.01, 0, 0.1, 0.9, 0.1, 0.1, -1)
show_hudmessage(0 , "Time: %s ",time)
}

public timeleft()
{
static timeleft
timeleft = get_timeleft()
set_hudmessage(255, 0, 0, 0.95, 0.03, 0, 0.1, 0.9, 0.1, 0.1, -1)
show_hudmessage(0 , "Timeleft: %d:%02d ",timeleft / 60, timeleft % 60)
}

Should I add them as parameters then use them in the show_hudmessage(id,message) instead of the 0 ?

Last edited by SID12; 08-20-2019 at 13:22.
SID12 is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 08-20-2019 , 13:29   Re: How to show hud to individual players
Reply With Quote #4

Post in Suggestion/Request section if you're a beginner. Scripting help section is intended for people who at least have basic knowledge in scripting.
I don't know why you're setting a task, but here you go.
PHP Code:
#include < amxmodx >

enum ( += 1234 )
{
    
TASK_TIME,
    
TASK_TIMELEFT
}

public 
plugin_init( ) 
{
    
register_clcmd"say /thetime""The_time" );
    
register_clcmd"say_team /thetime""The_time" );
    
    
register_clcmd"say /timeleft""Timeleft" );
    
register_clcmd"say_team /timeleft""Timeleft" );
}

public 
The_timeid )
{
    if( 
task_existsid TASK_TIME ) )
    {
        
remove_taskTASK_TIME );
    }

    
set_task1.0"TaskTime", ( id TASK_TIME ) );
}

public 
Timeleftid )
{
    if( 
task_existsid TASK_TIMELEFT ) )
    {
        
remove_taskTASK_TIMELEFT );
    }

    
set_task1.0"TaskTimeLeft", ( id TASK_TIMELEFT ) );
}

public 
TaskTimeid )
{
    
id -= TASK_TIME;

    static 
szTime32 ];
    
get_time"%H:%M:%S"szTimecharsmaxszTime ) ); 
    
    
set_hudmessage255000.950.0100.10.90.10.1, -);
    
show_hudmessageid"Time: %s"szTime );
}

public 
TaskTimeLeftid )
{
    
id -= TASK_TIMELEFT;

    static 
iTimeleft;
    
iTimeleft get_timeleft( );
    
    
set_hudmessage255000.950.0300.10.90.10.1, -);
    
show_hudmessageid"Timeleft: %d:%02d", ( iTimeleft 60 ), ( iTimeleft 60 ) );

__________________

Last edited by edon1337; 08-20-2019 at 13:30.
edon1337 is offline
SID12
Junior Member
Join Date: May 2019
Old 08-20-2019 , 13:33   Re: How to show hud to individual players
Reply With Quote #5

Quote:
Originally Posted by edon1337 View Post
Post in Suggestion/Request section if you're a beginner. Scripting help section is intended for people who at least have basic knowledge in scripting.
I don't know why you're setting a task, but here you go.
PHP Code:
#include < amxmodx >

enum ( += 1234 )
{
    
TASK_TIME,
    
TASK_TIMELEFT
}

public 
plugin_init( ) 
{
    
register_clcmd"say /thetime""The_time" );
    
register_clcmd"say_team /thetime""The_time" );
    
    
register_clcmd"say /timeleft""Timeleft" );
    
register_clcmd"say_team /timeleft""Timeleft" );
}

public 
The_timeid )
{
    if( 
task_existsid TASK_TIME ) )
    {
        
remove_taskTASK_TIME );
    }

    
set_task1.0"TaskTime", ( id TASK_TIME ) );
}

public 
Timeleftid )
{
    if( 
task_existsid TASK_TIMELEFT ) )
    {
        
remove_taskTASK_TIMELEFT );
    }

    
set_task1.0"TaskTimeLeft", ( id TASK_TIMELEFT ) );
}

public 
TaskTimeid )
{
    
id -= TASK_TIME;

    static 
szTime32 ];
    
get_time"%H:%M:%S"szTimecharsmaxszTime ) ); 
    
    
set_hudmessage255000.950.0100.10.90.10.1, -);
    
show_hudmessageid"Time: %s"szTime );
}

public 
TaskTimeLeftid )
{
    
id -= TASK_TIMELEFT;

    static 
iTimeleft;
    
iTimeleft get_timeleft( );
    
    
set_hudmessage255000.950.0300.10.90.10.1, -);
    
show_hudmessageid"Timeleft: %d:%02d", ( iTimeleft 60 ), ( iTimeleft 60 ) );


Lol I'm not a beginner it wasn't about this plugin specifically this was a example I'm using it for something else thx though
SID12 is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 08-20-2019 , 13:35   Re: How to show hud to individual players
Reply With Quote #6

Quote:
Originally Posted by SID12 View Post
Lol I'm not a beginner
Well, not trying to turn you off, but looking at the code you provided, it looks pretty bad.
__________________
edon1337 is offline
SID12
Junior Member
Join Date: May 2019
Old 08-20-2019 , 13:40   Re: How to show hud to individual players
Reply With Quote #7

Quote:
Originally Posted by edon1337 View Post
Well, not trying to turn you off, but looking at the code you provided, it looks pretty bad.
It's not mine it's an old plugin that showed people the time in the hud but it used the show_hudmessage function that s what i was interested in anyways enough with the off topic thx a lot again
SID12 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 14:45.


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