Raised This Month: $ Target: $400
 0% 

small text plug-in


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
DarlD
Senior Member
Join Date: Aug 2004
Old 08-28-2004 , 14:13   small text plug-in
Reply With Quote #1

would it be possible that some one posted a small text-on-screen plug-in that i could study?
DarlD is offline
Send a message via MSN to DarlD
jtp10181
Veteran Member
Join Date: May 2004
Location: Madison, WI
Old 08-28-2004 , 18:55  
Reply With Quote #2

where do you want this text? what kind of text?

center print?
status message?
HUD Message?
Chat message?
__________________
jtp10181 is offline
Send a message via ICQ to jtp10181 Send a message via AIM to jtp10181 Send a message via MSN to jtp10181 Send a message via Yahoo to jtp10181
DarlD
Senior Member
Join Date: Aug 2004
Old 08-28-2004 , 19:04  
Reply With Quote #3

anywhere in center i guess, i just want a small script easy to learn and that could start me out!
DarlD is offline
Send a message via MSN to DarlD
Peli
Veteran Member
Join Date: Mar 2004
Location: San Diego, CA
Old 08-28-2004 , 23:27  
Reply With Quote #4

Here is the code for a hud message in red that says "TEST" for 5 seconds at the start of the round :
Code:
public plugin_init() {   register_plugin("Test","0.1","DarlD")   register_event("ResetHUD","new_round","b") } public new_round(id) {   set_hudmessage(255, 0, 0, -1.0, -1.0, 0, 6.0, 5.0, 0.5, 1.5, 4)   show_hudmessage(0, "TEST")     return PLUGIN_HANDLED }
Peli is offline
Send a message via MSN to Peli
DarlD
Senior Member
Join Date: Aug 2004
Old 08-29-2004 , 00:30  
Reply With Quote #5

Quote:
Originally Posted by Peli
Here is the code for a hud message in red that says "TEST" for 5 seconds at the start of the round :
Code:
public plugin_init() {   register_plugin("Test","0.1","DarlD")   register_event("ResetHUD","new_round","b") } public new_round(id) {   set_hudmessage(255, 0, 0, -1.0, -1.0, 0, 6.0, 5.0, 0.5, 1.5, 4)   show_hudmessage(0, "TEST")     return PLUGIN_HANDLED }
i dont get the end, the new_rround thing, i searched for it on WIKI but i cant find it. could i remplace the new round by a death?
DarlD is offline
Send a message via MSN to DarlD
Mugwump
Senior Member
Join Date: May 2004
Old 08-29-2004 , 00:46  
Reply With Quote #6

Sure you can, try this:


Code:
public plugin_init()
{
  register_plugin("Test","0.1","DarlD")
  register_event("DeathMsg", "death_event", "a")    
}

public death_event()
{
   new killer_id = read_data(1)   // Get the id of the killer
   new victim_id = read_data(2)  // Get the id of the victim
   
   new kname[32], vname[32]    // Create new string variables for names
   get_user_name(killer_id, kname, 31)  // Get the killer's name
   get_user_name(victim_id, vname, 31) // Get the victim's name

   set_hudmessage(255, 0, 0, -1.0, -1.0, 0, 6.0, 5.0, 0.5, 1.5, 4)
   show_hudmessage(0, "HUD Display: %s just killed %s", kname, vname)

   client_print(0, print_center, "Centered Text: %s just killed %s", kname, vname)
   client_print(0, print_chat, "Chat Text: %s just killed %s", kname, vname)

   return PLUGIN_HANDLED
}
The above illustrates a few things, player death's are hooked to the death_event() routine, the killer and victim ids are read using read_data, their names are retrieved with get_user_name() and then 3 forms of messages are used to show the text... BTW - the 0 in the client_print means send the message to all players, you can also just put an id there like killer_id if you wanted to target a specific person for the message.

-Mug
Mugwump is offline
DarlD
Senior Member
Join Date: Aug 2004
Old 08-29-2004 , 13:53  
Reply With Quote #7

so the new kname[32], vname[32]
kname me killername and vname means victimename right?
but what are the 32???
DarlD is offline
Send a message via MSN to DarlD
DarlD
Senior Member
Join Date: Aug 2004
Old 08-29-2004 , 13:57  
Reply With Quote #8

heres what i got right now

Code:
#include <amxmodx>

public plugin_init() 
{ 
  register_plugin("Test","0.1","DarlD") 
  register_event("ResetHUD","new_round","b") 
} 

public new_round(id) 
{ 
  set_hudmessage(255, 0, 0, -1.0, -1.0, 0, 6.0, 5.0, 0.5, 1.5, 4) 
  show_hudmessage(0, "TEST") 
    return PLUGIN_HANDLED
}

public death_event() 
{ 
   new killer_id = read_data(1)   // Get the id of the killer 
   new victim_id = read_data(2)  // Get the id of the victim 
    
   new kname[32], vname[32]    // Create new string variables for names 
   get_user_name(killer_id, kname, 31)  // Get the killer's name 
   get_user_name(victim_id, vname, 31) // Get the victim's name 

   set_hudmessage(255, 0, 0, -1.0, -1.0, 0, 6.0, 5.0, 0.5, 1.5, 4) 
   show_hudmessage(0, "HUD Display: %s just killed %s", kname, vname) 

   client_print(0, print_center, "Centered Text: %s just killed %s", kname, vname) 
   client_print(0, print_chat, "Chat Text: %s just killed %s", kname, vname) 

   return PLUGIN_HANDLED 
}
DarlD is offline
Send a message via MSN to DarlD
Votorx
Senior Member
Join Date: Jun 2004
Old 08-29-2004 , 17:12  
Reply With Quote #9

Quote:
so the new kname[32], vname[32]
kname me killername and vname means victimename right?
but what are the 32???
Err...maybe you should try learning smalls before trying to write plugins. There's a tutorial in the forums here (a few topics down) that give you the basics of smalls.

Btw, 32 is the number of slots in the string kname and vname.
__________________
Currently Looking for a mod team.
Votorx is offline
Send a message via AIM to Votorx Send a message via MSN to Votorx Send a message via Yahoo to Votorx
Mugwump
Senior Member
Join Date: May 2004
Old 08-29-2004 , 18:05  
Reply With Quote #10

You need to modify your plugin_init to be:

public plugin_init()
{
register_plugin("Test","0.1","DarlD")
register_event("ResetHUD","new_round","b")
register_event("DeathMsg", "death_event", "a") // you missed this one
}

You had the death_event() routine defined but unless you register_event the routine it wont ever be called...

-Mug
Mugwump 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 17:11.


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