AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How to show hud to individual players (https://forums.alliedmods.net/showthread.php?t=318223)

SID12 08-20-2019 13:04

How to show hud to individual players
 
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 :)

edon1337 08-20-2019 13:12

Re: How to show hud to individual players
 
Show the full code, most likely the player id is in the function parameters.

SID12 08-20-2019 13:18

Re: How to show hud to individual players
 
Quote:

Originally Posted by edon1337 (Post 2663965)
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 ?

edon1337 08-20-2019 13:29

Re: How to show hud to individual players
 
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 ) );



SID12 08-20-2019 13:33

Re: How to show hud to individual players
 
Quote:

Originally Posted by edon1337 (Post 2663973)
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 :)

edon1337 08-20-2019 13:35

Re: How to show hud to individual players
 
Quote:

Originally Posted by SID12 (Post 2663977)
Lol I'm not a beginner

Well, not trying to turn you off, but looking at the code you provided, it looks pretty bad.

SID12 08-20-2019 13:40

Re: How to show hud to individual players
 
Quote:

Originally Posted by edon1337 (Post 2663979)
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 :)


All times are GMT -4. The time now is 17:30.

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