Raised This Month: $ Target: $400
 0% 

Solved problem Syntax ArrayList SM 1.11


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
manhkst
Member
Join Date: May 2015
Location: Vietnammese
Old 02-28-2023 , 02:09   problem Syntax ArrayList SM 1.11
Reply With Quote #1

I created a function to list the dead clients and order the closest distance and put it in an array. then I create a new array and assign the return function value to the new array to use for other purposes
Quote:
stock ArrayList ClientSurDieInRange(int victimdie, float radius, float origin[3])
{
float vecOTargetDie[3], vecOTargetDie_i[3],vecOTargetDie_j[3];
int count_cd,tmp_client;
ArrayList l_iclients = ArrayList();
for(new i=1; i<=MaxClients; i++)
{
if (IsClientSurDie(i) && i!=victimdie)
{
GetClientAbsOrigin(i, vecOTargetDie);
if (GetVectorDistance(origin,vecOTargetDie) <= radius)
{
l_iclients.push(i);
}
}
}

for(new i=0; i < l_iclients.length; i++)
{
GetClientAbsOrigin(l_iclients[i], vecOTargetDie_i);
for(new j=i+1; j<l_iclients.length; j++)
{
GetClientAbsOrigin(l_iclients[j], vecOTargetDie_j);
if(GetVectorDistance(origin,vecOTargetDie_j) < GetVectorDistance(origin,vecOTargetDie_i))
{
tmp_client = l_iclients[i];
l_iclients[i]=l_iclients[j];
l_iclients[j]=tmp_client;
}
}
}

return l_iclients;
}
Quote:
ArrayList clientsInRange = ClientSurDieInRange(victimdie, radius, origin);
then I create a new ArrayList variable and assign the return function value but get an error. Maybe my syntax is wrong somewhere, can someone help me?
__________________
FD ʚïɞ Team
Blog: http://fleeingdeath.blogspot.com/

Last edited by manhkst; 02-28-2023 at 09:35.
manhkst is offline
Grey83
Veteran Member
Join Date: Dec 2014
Location: Ukraine
Old 02-28-2023 , 06:46   Re: problem Syntax ArrayList SM 1.11
Reply With Quote #2

PHP Code:
stock ArrayList ClientSurDieInRange(int victimdiefloat radius)
{
    if(
radius 0.0)
        return 
null;

    
int i 1num;
    
int[] clients = new int[MaxClients];

    
float origin[3];
    
float[] dist = new float[MaxClients], dist_s = new float[MaxClients];
    
GetClientAbsOrigin(victimdieorigin);

    for(
float vec[3], len<= MaxClientsi++) if(!= victimdie && IsClientSurDie(i))
    {
        
GetClientAbsOrigin(ivec);
        if((
len GetVectorDistance(originvec)) <= radius)
        {
            
clients[num] = i;
            
dist_s[num] = len;
            
dist[num++] = len;
        }
    }

    if(!
num)
        return 
null;

    
0;
    
SortFloats(dist_snum);

    
ArrayList l_iclients = new ArrayList();
    for(
int jnumi++)
    {
        for(
0numj++) if(clients[j] && dist_s[i] == dist[j])
        {
            
l_iclients.push(clients[j]);
            
clients[j] = 0;
            break;
        }
    }

    return 
l_iclients;
}

SomeFunction()
{

    
ArrayList clientsInRange ClientSurDieInRange(victimdie1024.0);

__________________
Grey83 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 11:40.


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