AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Player respawn event (https://forums.alliedmods.net/showthread.php?t=5406)

Haircut 08-31-2004 12:10

Player respawn event
 
Player respawn event, I'm looking for a way to do this.

Ive tried:
Code:
    register_event("ResetHUD","re_spawn","b")
but it doesn't seem to work all the time.

Maybe I'm doing something wrong, here is the whole plug-in (v0.16):

Code:
#include <amxmodx> #include <fun> //--------------------------------------------------------------------------// public plugin_init() {     register_plugin("Spawn Protection","0.1","Haircut")     register_cvar("amx_god","1")     register_cvar("amx_godtime","5")     register_event("ResetHUD","re_spawn","b") } public client_disconnect (id) {     if (task_exists(id))         remove_task(id)     return PLUGIN_CONTINUE } //--------------------------------------------------------------------------// public re_spawn(id) {    if (!(get_cvar_num("amx_god") == 1))       return PLUGIN_CONTINUE    set_user_godmode(id, 1)        new Float:protect_time = get_cvar_float("amx_godtime")        set_hudmessage( 255, 0, 0, -1.0, 0.4, 0, 6.0, protect_time, 0.5, 1.5, 2 )    show_hudmessage(id, "SPAWN PROTECTION IS ENABLED FOR %.0f SECONDS", protect_time)        set_task(protect_time, "god_off", id)    return PLUGIN_CONTINUE } //--------------------------------------------------------------------------// public god_off(id) {     set_user_godmode(id)     return PLUGIN_CONTINUE }

SidLuke 08-31-2004 12:31

quick look at this code and for me it should work.
ResetHUD event isn't always executed ?

I will try to check this later ( Now I going to play on your server :) )

Votorx 08-31-2004 13:55

You can try this, it works almost perfectly for when the round restarts:

Code:
register_event("RoundTime", "new_round", "bc") public new_round() {     if ( floatround(get_cvar_float("mp_roundtime") * 60.0) != read_data(1) ) return PLUGIN_CONTINUE     //Put the code you want to happen at a new round }

But that's for a new round. It seems like you want to call an event every time a person dies, respawn them and protect them for a certain amount of time, if this is the case then you should use

Code:
register_event("DeathMsg","Function", "a")

SidLuke 08-31-2004 17:45

He need this for DoD.... :lol:

Votorx 08-31-2004 17:54

>.> ok...but these functions aren't mod dependant are they?

Peli 08-31-2004 19:19

Is there spawn killing in DoD? :)

Haircut 09-01-2004 04:57

Therwe is spawn killing when the map is de_dust. That is de_dust on a DoD Server :)

So I need to have spawn protection for when players re-spawn.

Quote:

ResetHUD event isn't always executed ?
I don't know, all I know is the Text doesn't always appear, whether the client has god mode, well ... that's another thing.


Votorx

I did think about that but the problem is the way DoD re-spawns palyers. It happens in waves of something like 5-10 seconds (Server variable), not when the individual player dies.

This makes it difficult to know how long the player will have to wait until they respawn, as this can be anything from instantly to 10 seconds.

SidLuke 09-01-2004 05:03

so also use client_print(..) , show_message may not be displayed (only 4 shared chanels)

Votorx 09-01-2004 14:02

I see...Well ResetHUD isn't a very reliable event...

So you may want to do something like this:

Code:
new IsDead[32] public server_frame(){ new player[32], num get_players(player, num) for(new x = 0; x <= num, x++){ if(!is_user_alive(player[x]){ IsDead[x] = 1 } else if((is_user_alive(player[x])) && (IsDead[x] == 1)){ Set_Task(.1; "Whatever function to give them god") IsDead[x] = 0 } }

Try some like that to get whenever a player respawns.

Johnny got his gun 09-02-2004 04:59

With fakemeta this will probably be very easy. Hook the spawn function itself, and there you go. Maybe you want to hook the post one, and so the forward will be called right after a player has spawned (before is probably not a good idea). In the forward function check if entity is 1 <=> maxplayers, and then set him to godmode for a few secs... and maybe a settask to ungodmode back in 5 secs... I just guess DoD also uses the Spawn function to respawn players.


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

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