AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   AutoRespawn plugin... Not working... (https://forums.alliedmods.net/showthread.php?t=40615)

smarttart62 06-30-2006 09:33

AutoRespawn plugin... Not working...
 
Well im trying to make another plugin in which you basically auto-respawn when you die...
Code:
#include <amxmodx> #include <amxmisc> #include <fun> #define PLUGIN "AutoSpawn" #define VERSION "1.0" #define AUTHOR "Smarttart62" public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR);     register_cvar("amx_autospawn","1");     register_event("Death","spawnMe","a"); } public spawnMe(){     if (get_cvar_num("amx_autospawn")!=1){         return PLUGIN_HANDLED;     }         new players[32],num;     get_players(players,num);         new ii;     for (ii=0;ii<num;ii++)     {         if (!is_user_alive(ii)){             spawn(ii);             set_task(0.5,"respawn",ii);         }     }         return PLUGIN_CONTINUE; } public respawn(id){     spawn(id); }
It just wont respawn though... And also the cvar keeps saying that it cant be set in a multiplayer game...

Thanks,
-Steve

Gizmo 06-30-2006 10:58

Re: AutoRespawn plugin... Not working...
 
Code:
#include <amxmodx> #include <amxmisc> #include <fun> #define PLUGIN "AutoSpawn" #define VERSION "1.0" #define AUTHOR "Smarttart62" public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)     register_cvar("amx_autospawn","1")     register_event("DeathMsg","spawnMe","a") } public spawnMe() {           if (get_cvar_num("amx_autospawn")!=1)     {         return PLUGIN_HANDLED     }               new players[32], num     get_players(players, num)     new i     for (i = 0; i < num; i++)     {         new id = players[i]         if (!is_user_alive(id))         {                   spawn(id)             set_task(0.5, "respawn", id)         }     }     return PLUGIN_CONTINUE } public respawn(id) {         spawn(id) }

Look at that code an compare to yours and you will find your errors.

smarttart62 06-30-2006 11:12

Re: AutoRespawn plugin... Not working...
 
Thanks for the help, but it still has no effect in the game...
Code:
#include <amxmodx> #include <amxmisc> #include <fun> #define PLUGIN "AutoSpawn" #define VERSION "1.0" #define AUTHOR "Smarttart62" public plugin_init(){     register_plugin(PLUGIN, VERSION, AUTHOR);     register_cvar("amx_autospawn","1");     register_event("Death","spawnMe","a"); } public spawnMe(){     if (get_cvar_num("amx_autospawn")!=1){         return PLUGIN_HANDLED;     }         new players[32],num;     get_players(players,num);         new ii;     for (ii=0;ii<num;ii++)     {         new id=players[ii];         if (!is_user_alive(id)){             spawn(id);             set_task(0.5,"respawn",id);         }     }         return PLUGIN_CONTINUE; } public respawn(id){     spawn(id); }
And i still have that cvar problem..
-Steve

Gizmo 06-30-2006 11:25

Re: AutoRespawn plugin... Not working...
 
You did not check all of the code
Code:
register_event("Death","spawnMe","a");

change to

Code:
register_event("DeathMsg","spawnMe","a");

Hawk552 06-30-2006 12:27

Re: AutoRespawn plugin... Not working...
 
You should either do cs_user_spawn, or spawn twice (there's a bug in the HL engine)

Also, the way you made this is retarded. Every time one person dies, you check if everyone is dead and end up spawning only one person. On top of that, you don't take into account spectators or just joined players.

Use read_data(2), it gives you the victim of the DeathMsg.

smarttart62 06-30-2006 15:57

Re: AutoRespawn plugin... Not working...
 
Hey thanks so much.
Sorry, im just quite new at this so i havent got it all down yet :).

EDIT: Ugh now it crashes:
Code:
#include <amxmodx> #include <amxmisc> #include <fun> #define PLUGIN "AutoSpawn" #define VERSION "1.0" #define AUTHOR "Smarttart62" public plugin_init(){     register_plugin(PLUGIN, VERSION, AUTHOR);     register_cvar("amx_autospawn","1");     register_event("DeathMsg","spawnMe","a"); } public spawnMe(){     if (get_cvar_num("amx_autospawn")!=1){         return PLUGIN_HANDLED;     }         new player;     player=read_data(2);     spawn(player);     set_task(0.5,"respawn",player);     return PLUGIN_CONTINUE; } public respawn(id){     spawn(id); }

ERROR: SZ_GetSpace: overflow without FSB_ALLOWOVERFLOW set on Server Reliable Datagram.
-Steve

Hawk552 06-30-2006 16:10

Re: AutoRespawn plugin... Not working...
 
Do a set_task twice, the first one for 0.5 and the second for 0.7. You can't spawn the person right when they join.

smarttart62 06-30-2006 16:27

Re: AutoRespawn plugin... Not working...
 
It only happens when im about to die though. Like for example, i jumped off of somewhere i knew would kill me and then when i kit the ground and the life was deducted then it errored.

I think its something to do with read_data...
-Steve

Hawk552 06-30-2006 16:31

Re: AutoRespawn plugin... Not working...
 
Quote:

Originally Posted by smarttart62
It only happens when im about to die though. Like for example, i jumped off of somewhere i knew would kill me and then when i kit the ground and the life was deducted then it errored.

I think its something to do with read_data...
-Steve

Then check if(!read_data(1)) return PLUGIN_CONTINUE or something, even though if you fell and died it wouldn't respawn you.

Like I said, just add the set_tasks.

smarttart62 06-30-2006 16:35

Re: AutoRespawn plugin... Not working...
 
Hey, it worked.

Thanks so much Hawk!
-Steve


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

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