AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Restart Round? [Solved] (https://forums.alliedmods.net/showthread.php?t=63466)

Wilson [29th ID] 11-21-2007 18:41

Restart Round? [Solved]
 
In both Counter-Strike and Day of Defeat, restarting the round not only respawns all players (and resets flags in dod) but it also resets all entities.

This includes func_breakables, and other triggers in the map that were set off. These all return to their default state on round restarting.

Does anyone know how to achieve this without restarting the round through a console command, which would also respawn everyone?


I have tried looping through all entities and executing hamsandwich's Ham_DOD_RoundRespawn, but the plugin dies mid-loop and doesn't make it to the echo. When I perform it on an individual func_breakable, it makes it to the echo but nothing happens to the entity at all.

Code:
    static maxents;     maxents = global_get( glb_maxEntities );             for( new i = 1; i < maxents; i++ )         if( pev_valid(i) ) ExecuteHam( Ham_DOD_RoundRespawn, i );             console_print( id, "Reset All %i Entities", maxents );

One thing I did notice was that a func_breakable's pev_health is set to 100.0 or 150.0 before it is broken, when it is set to 0.0 or negative, depending on the damage done to it. In addition, after it "breaks," its pev_deadflag is set to 2. I have tried setting the health back to 100.0 and the deadflag back to 0 and using DLLFunc_Spawn on it, but all that happens is I can no longer walk through it - but there is no window there, visually.


Thanks in advance gents.

purple_pixie 11-22-2007 05:50

Re: Restart Round?
 
You did call Ham_DOD_RoundRespawnEnt, and not Ham_DOD_RoundRespawn, right?

The include file has it listed as Ham_DOD_RoundRespawn in the "Execute Params" but I suspect a typo.

I would assume it started the loop (and happily called RoundRespawn on the first 32 player ents) and then died when it hit a real ent.

Otherwise, I can't really help - sadly I have absolutely no time to do anything fun / investigative with AMX ... I can only write what I know how to do, as I cannot test anything.
(Coding at work ;-) )

Wilson [29th ID] 11-22-2007 09:32

Re: Restart Round?
 
It's amazing what a bloody typo can do to you.

I was so aware of the differences in these two...I guess I copied and pasted or something..not sure how this one slipped by.

Well, respawning an ent works perfectly now that I added "Ent" to the end. The problem is, the loop still doesn't work.

Code:
    static maxents;     maxents = global_get( glb_maxEntities );             for( new i = 1; i < maxents; i++ )         if( pev_valid(i) && !is_user_connected(i) ) ExecuteHam( Ham_DOD_RoundRespawnEnt, i );             console_print( id, "Reset All %i Entities", maxents );

It still never gets to the echo. I added the is_user_connected to make sure it wasn't a player.

Is there any way to check if the entity is a map-entity that is supposed to be respawned? Or another check I can do so that this loop works?

ConnorMcLeod 11-22-2007 10:05

Re: Restart Round?
 
spawnflags ?

Also you can start to loop at maxplayers + 1

purple_pixie 11-22-2007 10:11

Re: Restart Round?
 
Step one would be to put in:

"Attempting Respawn on ent %i ( %s )",ent,classname
execute_ham()
"Success"

So at least you know where it crashes.

Then you can look what's special about that first ent it didn't do, and maybe work out why.

Wilson [29th ID] 11-22-2007 11:36

Re: Restart Round? [Solved]
 
Thanks conorr, I started at maxplayers+1 and the loop works fine.
I was about to do what you suggested purple_pixie, but then...it worked :P

Thanks again for the help guys.


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

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