AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Hud Message Help (https://forums.alliedmods.net/showthread.php?t=168929)

enjoi. 10-06-2011 07:46

Hud Message Help
 
I'm trying to make a plugin with mp_roundtime 145 but I can't figure this out. I want it to announce the last bullet kill.


PHP Code:

#include <amxmodx>

#pragma semicolon 1

#define VERSION        "1.1"

public plugin_init()
{
    
register_plugin("Hud Advertising"VERSION"enjoi.");
    
    
set_task(145.0"ShowAdvert"___"b");
}

public 
ShowAdvert(id)
{
    new 
szName[32]; get_user_name(idszNamecharsmax(szName))
    
set_hudmessage(00255, -1.00.8500.012.00.10.2);  
    
show_hudmessage(0"Last Bullet By: %s"szName);


Can anybody help?

Edit: Just do the hudmessage in the code please. Thanks

Napoleon_be 10-06-2011 09:04

Re: Hud Message Help
 
PHP Code:

public ShowAdvert()
{
    new 
szName[32]; get_user_name(idszNamecharsmax(szName))
    
set_hudmessage(00255, -1.00.8500.012.00.10.2);  
    
show_hudmessage(0"Last Bullet By: %s"szName);



Erox902 10-06-2011 12:20

Re: Hud Message Help
 
Quote:

Originally Posted by enjoi. (Post 1569346)
I'm trying to make a plugin with mp_roundtime 145 but I can't figure this out. I want it to announce the last bullet kill.

Well ofcourse it wont work. You did'nt catch the last kill nor who did it.
Catch it in DeathMsg or ham_killed whatever you prefer and assign the name to a string wich you can print in the "round end" event instead of hardcoding 145,
plus then you don't need any set_task wich also means less lag :)

Quote:

Originally Posted by Napoleon_be (Post 1569434)
PHP Code:

public ShowAdvert()
{
    new 
szName[32]; get_user_name(idszNamecharsmax(szName))
    
set_hudmessage(00255, -1.00.8500.012.00.10.2);  
    
show_hudmessage(0"Last Bullet By: %s"szName);



I don't think this will help him either...
Since there is no "id" specified you can't get users name.
Wich equals you cannot print the users name.

Napoleon_be 10-06-2011 13:48

Re: Hud Message Help
 
Quote:

Originally Posted by Erox902 (Post 1569542)
Well ofcourse it wont work. You did'nt catch the last kill nor who did it.
Catch it in DeathMsg or ham_killed whatever you prefer and assign the name to a string wich you can print in the "round end" event instead of hardcoding 145,
plus then you don't need any set_task wich also means less lag :)

I don't think this will help him either...
Since there is no "id" specified you can't get users name.
Wich equals you cannot print the users name.

my bad, sorry.

PHP Code:

public ShowAdvert(id)
{
    new 
szName[32]; get_user_name(idszNamecharsmax(szName))
    
set_hudmessage(00255, -1.00.8500.012.00.10.2);  
    
show_hudmessage(0"Last Bullet By: %s"szName);



enjoi. 10-06-2011 15:11

Re: Hud Message Help
 
Thanks for helping guys. Ill see if this works. I'm just new to coding.

So its this?

#include <amxmodx>

#pragma semicolon 1

#define VERSION "1.1"

public plugin_init()
{
register_plugin("Hud Advertising", VERSION, "enjoi.");

set_task(145.0, "ShowAdvert", _, _, _, "b");
}

public ShowAdvert(id)
{
new szName[32]; get_user_name(id, szName, charsmax(szName))
set_hudmessage(0, 0, 255, -1.0, 0.85, 0, 0.0, 12.0, 0.1, 0.2);
show_hudmessage(0, "Last Bullet By: %s", szName);
}

Erox902 10-06-2011 16:19

Re: Hud Message Help
 
Quote:

Originally Posted by Napoleon_be (Post 1569587)
my bad, sorry.

PHP Code:

public ShowAdvert(id)
{
    new 
szName[32]; get_user_name(idszNamecharsmax(szName))
    
set_hudmessage(00255, -1.00.8500.012.00.10.2);  
    
show_hudmessage(0"Last Bullet By: %s"szName);



Did you read the above part?

Here is how I would've done it
PHP Code:

#include <amxmodx>
#include <amxmisc>

#define PLUGIN    "GetLastKiller"
#define AUTHOR    "Rtk.Esc"
#define VERSION    "0.1"

new szName[32//Killers name will be assigned to this string

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_event("DeathMsg""eventDeath""a")
    
register_logevent("eventRoundend"2"1=Round_End")
    
//use round ends logevent instead of hardcoding to it!
    /*if mp_roundtime is more than 9 it will just go down to 9 again,
    so you can't have mp_roundtime 145. That would be 145minutes
    and no matter what the mp_roundtime is, if you print the message
    at round end it will always be displayed then*/
}

public 
eventDeath()
{
    new 
killer read_data(1//get the killer
    
    
if (killer != read_data(2) ) //check so the killer was'nt killing himself
    
{
        
get_user_name(killerszNamesizeof(szName) - 1//get the name, then asign it to szName
    
}
}

public 
eventRoundend()
{
    
set_hudmessage(00255, -1.00.8500.010.0)
    
show_hudmessage(0"Last Kill By: %s"szName);/*changed to "killer"
    cuz' if you want the last one shooting someone you'll have to hook ham_takedamage
    or if you mean the last one firing a bullet you should probably hook primary attack*/



enjoi. 10-06-2011 16:45

Re: Hud Message Help
 
thx.

Erox902 10-06-2011 16:46

Re: Hud Message Help
 
no problem


All times are GMT -4. The time now is 19:44.

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