PDA

View Full Version : Medic plugin


strontiumdog
12-07-2006, 03:57 PM
I'm sure this has been done before.
But I wrote this because I couldn't find it anywhere else for DoD :D
The Realism Mod in DoD:S has a medic function and I wanted something similar for DoD1.3!

----------------------------------------------------------------------

When a player's health get below a set level (default 20hp), they can heal themselves. The screen darkens to black, rendering them vulnerable. The player will yell out medic in their language. Their health then gets set to the max health level (default 60hp).


CVARS:
amx_medic_maxhealth: set maximum health when healed (default 60)
amx_medic_minhealth: set minimum health before healing can happen (default 20)

Players in-game:
say /medic
say medic

(or bound to a key: bind "k" "say /medic")

Box Cutter
12-07-2006, 04:24 PM
This looks interesting. I will give it a try. Thank you.

strontiumdog
12-08-2006, 01:44 AM
BTW...code for anyone who wants it without downloading the zip...
Compiles just fine in 1.76b

#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <dodx>

// amx_medic coded/developed by StrontiumDog
// Plugin in use at TheVille.Org II - DoD v1.3 Custom Map Server FF ON
// 63.210.145.199:27015
// http://www.theville.org


new g_msgFade

public plugin_init()
{
register_plugin("amx_medic by StrontiumDog", "1.2b", "StrontiumDog")
register_concmd("amx_medic", "heal_player", ADMIN_SLAY, "<part of nick> - Use this to heal a player")
register_clcmd("say /medic","medic",0,"- Calls for medic when your health is below 20hp")
register_clcmd("say medic","medic",0,"- Calls for medic when your health is below 20hp")
register_cvar("amx_medic_maxhealth", "60") // max health a person can have when being healed(default 60)
register_cvar("amx_medic_minhealth", "20") // max health a person can have when being healed(default 20)
g_msgFade = get_user_msgid("ScreenFade")
}

public plugin_precache()
{
precache_sound("medic/bandage1.wav")
precache_sound("medic/us_medic.wav")
precache_sound("medic/germedic.wav")
precache_sound("medic/britmedic.wav")
}

public medic(id,level,cid)
{
new med_health = get_user_health(id) // get player health
new med_minhealth = get_cvar_num("amx_medic_minhealth")
new med_maxhealth = get_cvar_num("amx_medic_maxhealth")

// Is the map British or American (Thanks Diamond-Optic!)
new uk = dod_get_map_info(MI_ALLIES_TEAM)

new med_myname[33]
get_user_name(id, med_myname, 32)

// If player is dead, send message and exit
if(!is_user_alive(id))
{
client_print(id, print_chat, "[MEDIC] You are dead")
return PLUGIN_HANDLED
}

// If player's health is not below minhealth var, send message and exit
if(get_cvar_num("amx_medic_minhealth") < med_health)
{
client_print(id, print_chat, "[MEDIC] It's only a flesh wound. Get up and fight soldier!")
return PLUGIN_HANDLED;
}

// Play US medic sound
if ((get_user_team(id) == 1) && (uk == 0))
{
emit_sound(id, CHAN_AUTO, "medic/us_medic.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
}

// Play German medic sound
if (get_user_team(id) == 2)
{
emit_sound(id, CHAN_AUTO, "medic/germedic.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
}

// Play British medic sound
if ((get_user_team(id) == 1) && (uk == 1))
{
emit_sound(id, CHAN_AUTO, "medic/britmedic.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
}

//While player is being healed, fade the screen to black
ftb(id)

// Heal them
// Play bandage sound while being healed

set_user_health(id, med_maxhealth)
client_print(0, print_chat, "[MEDIC] &#37;s has been healed", med_myname)
emit_sound(id, CHAN_AUTO, "medic/bandage1.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)

return PLUGIN_HANDLED;
}


// Fades screen to black while player is being healed
public ftb(id)
{
message_begin(MSG_ONE, g_msgFade, {0,0,0}, id);
write_short(floatround(2.0*4096.0)); // fade lasts this long duration
write_short(floatround(4.0*4096.0)); // fade lasts this long hold time
write_short(2); // fade type in/out
write_byte(0); // fade red
write_byte(0); // fade green
write_byte(0); // fade blue
write_byte(225); // fade alpha: Change to 255 for complete blackness and recompile
message_end();

return PLUGIN_CONTINUE
}

diamond-optic
12-08-2006, 07:34 PM
....you could cut down on precache and download size by using the medic voices already in the game.. but that doesnt really matter :-\ lol

strontiumdog
12-08-2006, 08:23 PM
Slapping forehead....uh duh!
I forgot they had them built in, in the gcf!

BTW, is there any special way of calling them other than:

mit_sound(id, CHAN_AUTO, "player/germedic.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)

Is this the right folder even though it's part of the gcf?

diamond-optic
12-08-2006, 08:28 PM
emit_sound is the right way to make it as if they are saying it, tho instead of CHAN_AUTO you could use CHAN_VOICE (but it shouldnt really matter either way)

the sounds in the gcf are located in the player/ directory

britmedic.wav
germedic.wav
usmedic.wav

so maybe adding a team check on allies to check whether to play brit or us medic voice..

theres also a 'stopbleed.wav' sound in there but its not quite like the bandage sound you have attached...


btw.. i like your signature :-)

strontiumdog
12-08-2006, 08:37 PM
Thanks!!

One last question, and I won't bother you anymore.....:D

get_user_team(id)

1 is Allies
2 is Germans
3 is Spectators

How can you tell if the allied team is British....?

diamond-optic
12-08-2006, 08:38 PM
here's an example from the smoke grenade plugin:

new team = get_user_team(id)
new is_brit = dod_get_map_info(MI_ALLIES_TEAM)

// Check if its Allies, If so is it a brit map?
if(team == 1 && is_brit == 1)
sound_to_play = brit_smokeup
// Check if its Allies, cant be brit otherwise previous statement would have got it
else if(team == 1)
sound_to_play = us_smokeup
// otherwise must be german team
else
sound_to_play = ger_smokeupso you get the map info for the allies team, 1=brit

strontiumdog
12-08-2006, 08:40 PM
Thank you, sir...
You are awesome!

I'll make the changes and test it!

strontiumdog
12-08-2006, 09:25 PM
For the meantime
I've left the sounds outside in a separate folder so that people have the option of putting their own mono 8 bit sounds in there....I've had people complain they can never change the sounds to what they want!!

If you are hurting for pre-cache then change

public plugin_precache()
{
precache_sound("medic/bandage1.wav")
precache_sound("medic/us_medic.wav")
precache_sound("medic/germedic.wav")
precache_sound("medic/britmedic.wav")
}

to

public plugin_precache()
{
precache_sound("medic/bandage1.wav")
precache_sound("player/usmedic.wav")
precache_sound("player/germedic.wav")
precache_sound("player/britmedic.wav")

}

and

// Play US medic sound
if ((get_user_team(id) == 1) && (uk == 0))
{
emit_sound(id, CHAN_AUTO, "medic/us_medic.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
}

// Play German medic sound
if (get_user_team(id) == 2)
{
emit_sound(id, CHAN_AUTO, "medic/germedic.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
}

// Play British medic sound
if ((get_user_team(id) == 1) && (uk == 1))
{
emit_sound(id, CHAN_AUTO, "medic/britmedic.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
}

to

// Play US medic sound
if ((get_user_team(id) == 1) && (uk == 0))
{
emit_sound(id, CHAN_AUTO, "player/usmedic.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
}

// Play German medic sound
if (get_user_team(id) == 2)
{
emit_sound(id, CHAN_AUTO, "player/germedic.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
}

// Play British medic sound
if ((get_user_team(id) == 1) && (uk == 1))
{
emit_sound(id, CHAN_AUTO, "player/britmedic.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
}

The us_medic.wav is from DoD:S and I think sounds much better....:D

diamond-optic
12-08-2006, 09:52 PM
you should also precache the defualt dod medic sound files too when using them instead of the new ones

strontiumdog
12-09-2006, 12:21 AM
Yup...did that and changed it....after making the server go boom!
Thanks for your help!

{RSR}Crazyhorse_cdn
04-15-2010, 11:12 PM
so i take it the sound wav. file is included and i dont have to roll up my sleeves to install this plug in ?? or do i have to bang my head then roll up sleeves ??

Sohood
04-16-2010, 01:26 AM
Just what im looking for, thank you sooo much!

{RSR}Crazyhorse_cdn
04-18-2010, 01:20 PM
i installed this plug in but cant get it to work ?? any ideas what i did wrong ?
i put the amxx in the plug ins folder and the sounds in the sound folder but cant seem to get it to work ??

{RSR}Crazyhorse_cdn
04-20-2010, 07:39 AM
here is what my modules.ini looks like :



;;;
; To enable a module, remove the semi-colon (;) in front of its name.
; If it's not here, simply add it its name, one per line.
; You don't need to write the _amxx part or the file extension.
;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;
;; SQL Modules usually need to be enabled manually ;;
;; You can have any number on at a time. Use ;;
;; amx_sql_type in sql.cfg to specify the default ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;

;mysql
;sqlite

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;
;; Put third party modules below here. ;;
;; You can just list their names, without the _amxx ;;
;; or file extension. ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;
;; These modules will be auto-detected and loaded ;;
;; as needed. You do not need to enable them here ;;
;; unless you have problems. ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;

fun
;engine
;fakemeta
;geoip
;sockets
;regex
;nvault
dodfun
dodx
;hamsandwich




these are my plug ins :


; AMX Mod X plugins

; Admin Base - Always one has to be activated
admin.amxx ; admin base (required for any admin-related)
;admin_sql.amxx ; admin base - SQL version (comment admin.amxx)

; Basic
admincmd.amxx ; basic admin console commands
adminhelp.amxx ; help command for admin console commands
adminslots.amxx ; slot reservation
multilingual.amxx ; Multi-Lingual management

; Menus
menufront.amxx ; front-end for admin menus
cmdmenu.amxx ; command menu (speech, settings)
plmenu.amxx ; players menu (kick, ban, client cmds.)
;telemenu.amxx ; teleport menu (Fun Module required!)
mapsmenu.amxx ; maps menu (vote, changelevel)
pluginmenu.amxx ; Menus for commands/cvars organized by plugin

; Chat / Messages
adminchat.amxx ; console chat commands
antiflood.amxx ; prevent clients from chat-flooding the server
scrollmsg.amxx ; displays a scrolling message
imessage.amxx ; displays information messages
adminvote.amxx ; vote commands

; Map related
nextmap.amxx ; displays next map in mapcycle
;mapchooser.amxx ; allows to vote for next map
timeleft.amxx ; displays time left on map

; Configuration
pausecfg.amxx ; allows to pause and unpause some plugins
statscfg.amxx ; allows to manage stats plugins via menu and commands

; Day of Defeat
stats.amxx ; stats on death or round end (DoD Module required!)
statssounds.amxx ; precache plugin for stats plugins
stats_logging.amxx ; weapons stats logging (DoD Module required!)

; Enable to use AMX Mod plugins
amxmod_compat.amxx ; AMX Mod backwards compatibility layer

; Custom - Add 3rd party plugins here


loadingsounddir.amxx
ps_heatmaps.amxx
dod_kamikaze.amxx
dod_blockexploits.amxx
WeaponsMod2.amxx
dod_teammanager.amxx
dod_respawnctrl.amxx
dod_eviladmin.amxx
dod_dropgrenades2.amxx
dod_tkrevenge.amxx
amx_parachute.amxx
dod_giveammo.amxx
dod_gore_custom.amxx
dod_improved_registry.amxx
dod_killinfo.amxx
dod_meleebonus.amxx
dod_customize_flags.amxx
deagsmapmanager.amxx
dod_rocketclass.amxx
hd_main.amxx
hd_bhophacks.amxx
hd_kzhack.amxx
dod_medic.amxx


I still can't figure out what the heck is going on ??

{RSR}Crazyhorse_cdn
04-20-2010, 07:57 PM
after a long day of looking at each plugin finally found out that th eweapons mod2 plugin is conflicting with the other plug ins i have so now my medic is working woohoo