Raised This Month: $ Target: $400
 0% 

3 simple questions


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Obbin
Senior Member
Join Date: Mar 2005
Location: 192.168.1.3
Old 12-22-2005 , 08:29   3 simple questions
Reply With Quote #1

how to catch/hook "%s dropped the bomb" and "%s hans picked up the bomb"?
how to show solid text in the middle of the screen (that such of text used in "%s picked up/dropped the bomb")?
__________________
Sig(h)!
Obbin is offline
Bruno
Member
Join Date: Jun 2005
Old 12-22-2005 , 09:34   Re: 3 simple questions
Reply With Quote #2

Quote:
Originally Posted by obbin
how to catch/hook "%s dropped the bomb" and "%s hans picked up the bomb"?
how to show solid text in the middle of the screen (that such of text used in "%s picked up/dropped the bomb")?
The %s is used with the function get_user_name there. To print something in the center, you can use
Code:
client_print(id,print_center," TYpe what you want here ^n")
__________________
If you have but one shot at an opportunity, make it count.
Bruno is offline
Bruno
Member
Join Date: Jun 2005
Old 12-22-2005 , 09:49  
Reply With Quote #3

Here is an example using the get_user_name function
Code:
new name[33] get_user_name(id,name,sizeof(name)) client_print(id,print_chat,"Text goes here^n",name)
__________________
If you have but one shot at an opportunity, make it count.
Bruno is offline
Viper944812627
New Member
Join Date: Dec 2005
Old 12-22-2005 , 09:57  
Reply With Quote #4

What do you mean catch/hook?
Viper944812627 is offline
Obbin
Senior Member
Join Date: Mar 2005
Location: 192.168.1.3
Old 12-22-2005 , 15:48  
Reply With Quote #5

I mean when that message is displayed to the T's then start a function!
__________________
Sig(h)!
Obbin is offline
VEN
Veteran Member
Join Date: Jan 2005
Old 12-22-2005 , 23:37  
Reply With Quote #6

Code:
// public plugin_init() {     register_event("TextMsg", "event_drop", "bc", "2=#Game_bomb_drop")     register_event("TextMsg", "event_got", "b", "2=#Got_bomb") } public event_drop() {     new name[32]     read_data(3, name, 31)     new id = get_user_index(name)     // ... } public event_got(id) {     // ... }
VEN is offline
Obbin
Senior Member
Join Date: Mar 2005
Location: 192.168.1.3
Old 12-23-2005 , 03:58  
Reply With Quote #7

thx VEN!

EDIT: I meant the #Game_bomb_pickup message, should that message have the "bc" flags aswell

EDIT #2: How to detect the flags of a message like that and how to replace a message?
And how to get the #id of a person that gets a "Personal message" like "You picked up the bomb"
Does this work to replace a message:
Code:
public replace_Bomb_Planted(){ client_print(0, print_center, "This message replaced ^"The bomb has been planted^"")     return PLUGIN_HANDLED }
__________________
Sig(h)!
Obbin is offline
MaximusBrood
Veteran Member
Join Date: Sep 2005
Location: The Netherlands
Old 12-23-2005 , 08:49  
Reply With Quote #8

If you take it from the code Ven posted:

Code:
#include <amxmodx>
#include <amxmisc>

public plugin_init() {
    register_event("TextMsg", "event_drop", "bc", "2=#Game_bomb_drop")
    register_event("TextMsg", "event_got", "b", "2=#Got_bomb")
}

public event_drop() {
	new name[32]
	read_data(3, name, 31)
	new id = get_user_index(name)
	
	//Get all terrorists
	new players[32], playernum, a
	get_players(players, playernum, "ce", "TERRORIST")
	
	//Use a for loop to show all the messages
	for(a = 0; a < playernum; a++)
	{
		//Check if it isn't the player who dropped the bomb
		if(players[a] != id)
		{
			client_print(players[a], print_chat, "[AMX] %s dropped the bomb")
		}
	}
    
	//Now give the dropper a personal message
	client_print(id, print_chat, "[AMXX] You lost the bomb")
	
    
	//To make sure original message isn't shown
	return PLUGIN_HANDLED
}

public event_got(id) {
    // same here :)
}
__________________
Released six formerly private plugins. Not active here since ages.
MaximusBrood is offline
VEN
Veteran Member
Join Date: Jan 2005
Old 12-23-2005 , 10:57  
Reply With Quote #9

Code:
//To make sure original message isn't shown  return PLUGIN_HANDLED
No this wouldn't block original message.
You cant block messages with this way.
But you can use engine register_message for such purpose.

Quote:
I meant the #Game_bomb_pickup message, should that message have the "bc" flags aswell
Yes.
"b" flag mean that you want to catch specified event.
"c" flag mean that you do not want to repeat your event function if the same event repeats for more than one person.

Example: DeathMsg event is global so you should put "a" flag.

Code:
register_event("DeathMsg", "event_death", "a")
You can get killer id, victim id is headshot or not and weapon name from this event. You can get all message's arguments with read_data.
Example:
Code:
// public event_death() {     new killer_id = read_data(1)     new victim = read_data(2)     new headshot = read_data(3)     new weapon[32]     read_data(4, weapon, 31)     // ... }

Quote:
How to detect the flags of a message like
I use Damaged Soul's "Message Logging" plugin it's very useful since it can tell you everithing you need about messages(events).

Quote:
how to replace a message
It depent on message type.
You can replace center text messages by sending your own center text message with
Code:
client_print(id, print_center, "Hello")
If you want to replace other messages like console text you should use engine register_message. It allow catch/change messages.

Quote:
how to get the #id of a person that gets a "Personal message" like "You picked up the bomb"
Code:
public plugin_init() {     register_event("TextMsg", "event_got", "b", "2=#Got_bomb") } public event_got(id) {     // id - is id of a person who picked up the bomb     // that's why we call such events "specified" }
Quote:
Does this work to replace a message
Yes. But as i said before you can't overwrite any message with this method. This method not block the message but only overwrite.
So if i would like to overwrite "(Radio) Fire in the hole" message this wouldn't work.
The only way to overwrite any message it's a change message with engine register_message.
VEN is offline
Obbin
Senior Member
Join Date: Mar 2005
Location: 192.168.1.3
Old 12-23-2005 , 11:21  
Reply With Quote #10

thx VEN, that was all!
K++
__________________
Sig(h)!
Obbin is offline
Reply


Thread Tools
Display Modes

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 15:49.


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