AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   small text plug-in (https://forums.alliedmods.net/showthread.php?t=5320)

DarlD 08-28-2004 14:13

small text plug-in
 
would it be possible that some one posted a small text-on-screen plug-in that i could study?

jtp10181 08-28-2004 18:55

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

center print?
status message?
HUD Message?
Chat message?

DarlD 08-28-2004 19:04

anywhere in center i guess, i just want a small script easy to learn and that could start me out!

Peli 08-28-2004 23:27

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 }
:)

DarlD 08-29-2004 00:30

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?

Mugwump 08-29-2004 00:46

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

DarlD 08-29-2004 13:53

so the new kname[32], vname[32]
kname me killername and vname means victimename right?
but what are the 32???

DarlD 08-29-2004 13:57

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
}


Votorx 08-29-2004 17:12

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.

Mugwump 08-29-2004 18:05

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


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

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