AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   register death event for everyone (https://forums.alliedmods.net/showthread.php?t=3623)

ngsucks 07-10-2004 19:01

register death event for everyone
 
I want to find out when someone dies on both ct and t. so i can make it so whn somoene dies, my hero gets health and money!

[edit] get_user_health and set_user_healtha nd all of that is suppose to have a cs infront, i know im just too lazy to go back and put it...[/edit]
for example


register_plugin() {

register_event( "Death", "wdeath", "b" );

return PLUGIN_CONTINUE;
}

public wdeath( wht do put here? ) {

new temp[6]
// First Argument is an id
read_argv(1,temp,5)
new id=str_to_num(temp)

set_user_health(get_user_health(id) + 25)
set_user_money(get_user_money(id) + 400)

return PLUGIN_CONTINUE;
}

SidLuke 07-10-2004 19:42

register_event( "DeathMsg", "wdeath", "a" ); when you put b there this function won't be ever executed .

Code:

* Flags:
* "a" - global event.
* "b" - specified.
* "c" - send only once when repeated to other players.
* "d" - call if is send to dead player.
* "e" - to alive.

Code:

public wdeath(){
  // read killer and victim
  new killer = read_data(1)
  new victim = read_data(2)

  if ( !killer || killer == victim)  // not valid kill , suicide
    return PLUGIN_CONTINUE

  if ( get_uset_team(killer) == get_user_team(victim) ) // TK
    return PLUGIN_CONTINUE

  // awards for killer
  set_user_health(get_user_health(killer) + 25)
  cs_set_user_money(cs_get_user_money(victim) + 400)
 
}


ngsucks 07-10-2004 21:12

thanks ur the best!
problem, it says "function wdeath should return a value?

Code:

register_event( "DeathMsg", "wdeath", "a" );



public wdeath()
{
// read killer and victim
new killer = read_data(1)
new victim = read_data(2)

if ( !killer || killer == victim) // not valid kill , suicide
return PLUGIN_CONTINUE

if ( get_user_team(killer) == get_user_team(victim) ) // TK
return PLUGIN_CONTINUE

// awards for killer
set_user_health(killer, get_user_health(killer) + 25)
set_user_money(killer, get_user_money(killer) + 400)
}

but if i do this, it works:
Code:

public wdeath()
{
// read killer and victim
new killer = read_data(1)
//new victim = read_data(2)

// awards for killer
set_user_health(killer, get_user_health(killer) + 25)
set_user_money(killer, get_user_money(killer) + 400)
}


SidLuke 07-11-2004 07:36

Code:

public plugin_init(){
register_event( "DeathMsg", "wdeath", "a" );
}

public wdeath()
{
// read killer and victim
new killer = read_data(1)
new victim = read_data(2)

if ( !killer || killer == victim) // not valid kill , suicide
return PLUGIN_CONTINUE

if ( get_user_team(killer) == get_user_team(victim) ) // TK
return PLUGIN_CONTINUE

// awards for killer
set_user_health(killer, get_user_health(killer) + 25)
set_user_money(killer, get_user_money(killer) + 400)

//more code here if you want

return PLUGIN_CONTINUE  // final return , end function
}


ngsucks 07-11-2004 16:56

I love u, man....thanks

it works perfectly even though im unsure whts diff from whts he wrote before you.. can you tell me wht the difference was..


THANKS!


All times are GMT -4. The time now is 14:46.

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