AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Stop this while loop? (https://forums.alliedmods.net/showthread.php?t=89018)

VMAN 03-31-2009 23:02

Stop this while loop?
 
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.

Bugsy 03-31-2009 23:11

Re: Stop this while loop?
 
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");
        }



VMAN 03-31-2009 23:57

Re: Stop this while loop?
 
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.

Exolent[jNr] 04-01-2009 07:20

Re: Stop this while loop?
 
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});



SchlumPF* 04-01-2009 07:37

Re: Stop this while loop?
 
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
    



VMAN 04-01-2009 19:54

Re: Stop this while loop?
 
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 -.-)

Exolent[jNr] 04-01-2009 20:06

Re: Stop this while loop?
 
Try spawning the entity with DLLFunc_Spawn.

VMAN 04-01-2009 21:03

Re: Stop this while loop?
 
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 :cry:

SchlumPF* 04-02-2009 15:14

Re: Stop this while loop?
 
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)

Exolent[jNr] 04-02-2009 15:50

Re: Stop this while loop?
 
Try creating the entity in plugin_precache().


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

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