AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   de_airstrip hates my function?? (https://forums.alliedmods.net/showthread.php?t=61783)

GHW_Chronic 10-09-2007 14:23

de_airstrip hates my function??
 
Code:
public force_spin() {     log_amx("Start")     if(get_pcvar_num(toggle_pcvar))     {         static classname[16], Float:angles[3]         new ent = engfunc(EngFunc_FindEntityInSphere,maxplayers,Float:{0.0,0.0,0.0},4800.0)         while(ent)         {             log_amx("%d",ent)             if(pev_valid(ent))             {                 pev(ent,pev_classname,classname,15)                 if(containi(classname,"armoury")!=-1 || containi(classname,"weaponbox")!=-1)                 {                     pev(ent,pev_angles,angles)                     angles[1] += get_pcvar_float(speed_pcvar) / 10.0                     if(angles[1]>=180.0)                     {                         angles[1] -= 360.0                     }                     set_pev(ent,pev_angles,angles)                 }             }             ent = engfunc(EngFunc_FindEntityInSphere,ent,Float:{0.0,0.0,0.0},4800.0)         }     }     log_amx("End") }

This function is from my UT style weapon floating plugin. It works fine on every map I have except airstip. I have it set to execute the above statement ONCE from plugin_init in a test plugin. that's all that happens. It executes once and no other 3rd party plugin is running. Here is the log i get out:

Code:

L 10/09/2007 - 13:18:06: [GHW_Floating_Weapons.amxx] Start
L 10/09/2007 - 13:18:06: [GHW_Floating_Weapons.amxx] 34
L 10/09/2007 - 13:18:06: [GHW_Floating_Weapons.amxx] (Lots of ent numbers)
L 10/09/2007 - 13:18:06: [GHW_Floating_Weapons.amxx] 407
L 10/09/2007 - 13:18:06: [GHW_Floating_Weapons.amxx] 34
L 10/09/2007 - 13:18:06: [GHW_Floating_Weapons.amxx] (Lots of ent numbers)
L 10/09/2007 - 13:18:06: [GHW_Floating_Weapons.amxx] 407

The end is never printed into the log file. It appears that this:
Code:
engfunc(EngFunc_FindEntityInSphere,407,Float:{0.0,0.0,0.0},4800.0)
is returning 34... I had like 2 hours of sleep a couple days ago so I think it could be a typo of some sort but I really don't know... and I don't know why it only happens on airstrip...

M249-M4A1 10-09-2007 16:53

Re: de_airstrip hates my function??
 
There is some weird infinite loop going on for that map

alien 10-09-2007 17:12

Re: de_airstrip hates my function??
 
I had very funny problems with sphere functions. Honestly, I set it up to search entities in radius of 128 units from player's origin. Then I calculated distance from found entity. In most cases, it was below 128 but in some, it found entities even further (much further).

Have you tried cs_siege?

creeperdank 06-15-2008 18:20

Re: de_airstrip hates my function??
 
de_torn crashes my server as well.

Vet 06-16-2008 01:08

Re: de_airstrip hates my function??
 
I ran your snippet on several maps, including airstrip and torn, and didn't have any problems.
I did add a client command
Code:

register_clcmd("say /spin", "force_spin", 0, "Spins ents")
so I could control the spin manually. Also, I moved the
Code:

log_amx("%d",ent)
statement to after the compare as to not print out all the unecessary entities.

GHW_Chronic 06-16-2008 16:43

Re: de_airstrip hates my function??
 
well then it is clear that there is some variable different between the two of us that stops this line of code from working properly.

me:
listenserver
windows
AMXX 1.8
no 3rd party plugins

Vet 06-17-2008 08:04

Re: de_airstrip hates my function??
 
I ran it on:
Dedicated server on LAN
Windows XP
Amxx 1.8
Lots of other plugins

Weird.

Vet 06-17-2008 16:32

Re: de_airstrip hates my function??
 
2 Attachment(s)
Here's the sma of the routine I used. Just "say /spin" and the weapons rotate and the log looks OK.

travo 06-19-2008 16:21

Re: de_airstrip hates my function??
 
I always get mixed results with findentinsphere, i prefer to loop through all the ents and check the classname as its give me better results and is probably a lot more economical and less cpu than findentinsphere.
I also hate using static variables because I never get any consistance (i probably use them wrong half the time lol) so I stick with new style variables.

PHP Code:

public plugin_init()
    
set_task(0.1"force_spin"___"b");

public 
force_spin()
    if (
get_timeleft())
    {
        new 
classname[11], Float:angles[3], ent = -1ent_total engfunc(EngFunc_NumberOfEntities) + 30;
        while (
ent++ < ent_total)
            if (
pev_valid(ent))
            {
                
pev(entpev_classnameclassname10);
                if (
containi(classname"armoury") != -|| containi(classname"weaponbox") != -1)
                {
                    
pev(entpev_anglesangles);
                    
//angles[1] += get_pcvar_float(speed_pcvar) / 10.0;
                    
angles[1] += 27.0;
                    if(
angles[1] >= 180.0)
                        
angles[1] -= 360.0;
                    
set_pev(entpev_anglesangles);
                }
            }
    } 



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

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