Raised This Month: $ Target: $400
 0% 

Stop this while loop?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
VMAN
Senior Member
Join Date: Oct 2007
Location: California, US
Old 03-31-2009 , 23:02   Stop this while loop?
Reply With Quote #1

PHP Code:
public strip_spawns() {
        new 
tspawns;
        new 
ctspawns;
        while((
tspawns engfunc(EngFunc_FindEntityByString, -1"classname""info_player_deathmatch")) !=0) {
            
engfunc(EngFunc_RemoveEntitytspawns);
        }
        while((
ctspawns engfunc(EngFunc_FindEntityByString, -1"classname""info_player_start")) !=0) {
            
engfunc(EngFunc_RemoveEntityctspawns);
        }

How do I make the loop stop after it deletes the last spawn?

After my plugin deletes the old spawns, it creates the new spawns in my new locations, but they are still being deleted by the loop.
VMAN is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 03-31-2009 , 23:11   Re: Stop this while loop?
Reply With Quote #2

Are you sure your spawns are being created successfully? Try this just to verify that they are getting deleted by the loops.

PHP Code:
public strip_spawns() {
        new 
tspawns;
        new 
ctspawns;
        while((
tspawns engfunc(EngFunc_FindEntityByString, -1"classname""info_player_deathmatch")) !=0) {
            
engfunc(EngFunc_RemoveEntitytspawns);
            
server_print("deleted t spawn");
        }
        while((
ctspawns engfunc(EngFunc_FindEntityByString, -1"classname""info_player_start")) !=0) {
            
engfunc(EngFunc_RemoveEntityctspawns);
            
server_print("deleted ct spawn");
        }

__________________
Bugsy is offline
VMAN
Senior Member
Join Date: Oct 2007
Location: California, US
Old 03-31-2009 , 23:57   Re: Stop this while loop?
Reply With Quote #3

After I strip the spawns, I call this
PHP Code:
public create_test_spawn() {
    new 
tspawn1 engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"info_player_deathmatch"));
        
engfunc(EngFunc_SetOrigintspawn1"953 412 46");
        
set_pev(tspawn1pev_angles"0 180 0");


But I can't select the terrorists team when I join..so I'm assuming the spawn was not created or it was being deleted by my while loop.

Last edited by VMAN; 04-01-2009 at 00:05.
VMAN is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 04-01-2009 , 07:20   Re: Stop this while loop?
Reply With Quote #4

PHP Code:
public create_test_spawn() {
    new 
tspawn1 engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"info_player_deathmatch"));
        
engfunc(EngFunc_SetOrigintspawn1Float:{953.0412.046.0});
        
set_pev(tspawn1pev_anglesFloat:{0.0180.00.0});

__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
VMAN
Senior Member
Join Date: Oct 2007
Location: California, US
Old 04-01-2009 , 21:03   Re: Stop this while loop?
Reply With Quote #5

PHP Code:
public create_test_spawn() {
    new 
tspawn1 engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"info_player_deathmatch"));
        
engfunc(EngFunc_SetOrigintspawn1Float:{95341246});
        
set_pev(tspawn1pev_anglesFloat:{01800});
        
dllfunc(DLLFunc_Spawntspawn1);

Still doesn't do it
VMAN is offline
SchlumPF*
Veteran Member
Join Date: Mar 2007
Old 04-01-2009 , 07:37   Re: Stop this while loop?
Reply With Quote #6

exolent already fixed create_test_spawn() (although it could be Float:{953, 412, 46} and Float:{0, 180, 0}, for {953.0, 412.0, 46.0} and {0.0, 180.0, 0.0} you dont need to add a float: in front).

also, look at this to fix your usage of EngFunc_FindEntityByString:
PHP Code:
    new ent = -1;
    while( ( 
ent engfunc(EngFunc_FindEntityByStringent"classname""info_player_deathmatch" ) ) != )
    {
        
// do sth
    

__________________
SchlumPF* is offline
Send a message via ICQ to SchlumPF*
VMAN
Senior Member
Join Date: Oct 2007
Location: California, US
Old 04-01-2009 , 19:54   Re: Stop this while loop?
Reply With Quote #7

I did what you both recommended.

The normal spawns are being removed, but my new spawn is not being created (can't join the terrorists team -.-)
VMAN is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 04-01-2009 , 20:06   Re: Stop this while loop?
Reply With Quote #8

Try spawning the entity with DLLFunc_Spawn.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
SchlumPF*
Veteran Member
Join Date: Mar 2007
Old 04-02-2009 , 15:14   Re: Stop this while loop?
Reply With Quote #9

maybe its cuz of the cs engine, i guess cs i registering all spawns while fm_setkeyvalue is run. this would mean any spawns created after this wont be accepted by the engine. (just a guess though)
__________________
SchlumPF* is offline
Send a message via ICQ to SchlumPF*
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 04-02-2009 , 15:50   Re: Stop this while loop?
Reply With Quote #10

Try creating the entity in plugin_precache().
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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