Methods of floats..
#1

Currently I have something like..

PHP код:
forward CreateTrees( );
public 
CreateTrees( )
{
    
treeExists ] = 1;
    
treeObj ] = CreateObject(691661.911289.5310.71,   3.140.000.16);
    
treePos ] [ ] = 661.91treePos ] [ ] = 1289.53treePos ] [ ] = 10.71;
    
    
treeExists ] = 1;
    
treeObj ] = CreateObject(691640.081289.3710.71,   3.140.00, -296.78);
    
treePos ] [ ] = 640.08treePos ] [ ] = 1289.37treePos ] [ ] = 10.71;
    
    
treeExists ] = 1;
    
treeObj ] = CreateObject(691685.151257.1410.71,   3.140.00, -409.52);
    
treePos ] [ ] = 685.15treePos ] [ ] = 1257.14treePos ] [ ] = 10.71;
    
    
treeExists ] = 1;
    
treeObj ] = CreateObject(691695.251231.5910.14,   3.140.00, -409.52);
    
treePos ] [ ] = 695.25treePos ] [ ] = 1231.59treePos ] [ ] = 10.14;
    
    
treeExists ] = 1;
    
treeObj ] = CreateObject(691661.871190.0510.71,   3.140.000.16);
    
treePos ] [ ] = 661.87treePos ] [ ] = 1190.05treePos ] [ ] = 10.71;
    
    
treeExists ] = 1;
    
treeObj ] = CreateObject(691639.621190.149.93,   3.140.002.64);
    
treePos ] [ ] = 639.62treePos ] [ ] = 1190.14treePos ] [ ] = 9.93;
    
    
treeExists ] = 1;
    
treeObj ] = CreateObject(691571.271256.6410.71,   3.140.00, -296.78);
    
treePos ] [ ] = 571.27treePos ] [ ] = 1256.64treePos ] [ ] = 10.71;
    
    
treeExists ] = 1;
    
treeObj ] = CreateObject(691554.251242.1510.71,   3.140.00, -296.78);
    
treePos ] [ ] = 554.25treePos ] [ ] = 1242.15treePos ] [ ] = 10.71;
    return 
true;

PHP код:
for( new tMAX_TREES++ )
        {
            if( 
IsPlayerInRangeOfPointplayerid5.0treePos ] [ ], treePos ] [ ], treePos ] [ ] ) && treeExists ] == )
            {
// snip... 
Now, this is an absolute pain in my ass to handle, so how could I convert that to an array or something easier?
Reply
#2

Oh sorry, offtop.
Reply
#3

like this?
Код:
forward CreateTrees( );
public CreateTrees( )
{
	for(new t=0;t<MAX_TREES;t++)
	{
		treeExists[t]=1;
		treeObj[t]=CreateObject(691,	treePos[t][0],	treePos[t][1],	treePos[t][2],3.14,0.00,0.16);
	}
	return 1;
}
did it in a hurry, but i hope it looks better. not tested.
oh, the array for the coordinates have to be defined somewhere else, like OnGame/FilterscriptInit:
Код:
treePos [ 0 ] [ 0 ] = 661.91, treePos [ 0 ] [ 1 ] = 1289.53, treePos [ 0 ] [ 2 ] = 10.71;
treePos [ 1 ] [ 0 ] = 640.08, treePos [ 1 ] [ 1 ] = 1289.37, treePos [ 1 ] [ 2 ] = 10.71;
treePos [ 2 ] [ 0 ] = 685.15, treePos [ 2 ] [ 1 ] = 1257.14, treePos [ 3 ] [ 2 ] = 10.71;
treePos [ 3 ] [ 0 ] = 695.25, treePos [ 3 ] [ 1 ] = 1231.59, treePos [ 3 ] [ 2 ] = 10.14;
treePos [ 4 ] [ 0 ] = 661.87, treePos [ 4 ] [ 1 ] = 1190.05, treePos [ 4 ] [ 2 ] = 10.71;
treePos [ 5 ] [ 0 ] = 639.62, treePos [ 5 ] [ 1 ] = 1190.14, treePos [ 5 ] [ 2 ] = 9.93;
treePos [ 6 ] [ 0 ] = 571.27, treePos [ 6 ] [ 1 ] = 1256.64, treePos [ 6 ] [ 2 ] = 10.71;
treePos [ 7 ] [ 0 ] = 554.25, treePos [ 7 ] [ 1 ] = 1242.15, treePos [ 7 ] [ 2 ] = 10.71;
done.
Reply
#4

Quote:
Originally Posted by Babul
Посмотреть сообщение
like this?
Код:
forward CreateTrees( );
public CreateTrees( )
{
	for(new t=0;t<MAX_TREES;t++)
	{
		treeExists[t]=1;
		treeObj[t]=CreateObject(691,	treePos[t][0],	treePos[t][1],	treePos[t][2],3.14,0.00,0.16);
	}
	return 1;
}
did it in a hurry, but i hope it looks better. not tested.
oh, the array for the coordinates have to be defined somewhere else, like OnGame/FilterscriptInit:
Код:
treePos [ 0 ] [ 0 ] = 661.91, treePos [ 0 ] [ 1 ] = 1289.53, treePos [ 0 ] [ 2 ] = 10.71;
treePos [ 1 ] [ 0 ] = 640.08, treePos [ 1 ] [ 1 ] = 1289.37, treePos [ 1 ] [ 2 ] = 10.71;
treePos [ 2 ] [ 0 ] = 685.15, treePos [ 2 ] [ 1 ] = 1257.14, treePos [ 3 ] [ 2 ] = 10.71;
treePos [ 3 ] [ 0 ] = 695.25, treePos [ 3 ] [ 1 ] = 1231.59, treePos [ 3 ] [ 2 ] = 10.14;
treePos [ 4 ] [ 0 ] = 661.87, treePos [ 4 ] [ 1 ] = 1190.05, treePos [ 4 ] [ 2 ] = 10.71;
treePos [ 5 ] [ 0 ] = 639.62, treePos [ 5 ] [ 1 ] = 1190.14, treePos [ 5 ] [ 2 ] = 9.93;
treePos [ 6 ] [ 0 ] = 571.27, treePos [ 6 ] [ 1 ] = 1256.64, treePos [ 6 ] [ 2 ] = 10.71;
treePos [ 7 ] [ 0 ] = 554.25, treePos [ 7 ] [ 1 ] = 1242.15, treePos [ 7 ] [ 2 ] = 10.71;
done.
Appreciate the effort. I was looking for something along the lines of a normal uhh... like..

PHP код:
new
    
FloatCivSpawns [] [] =
    {
        { 
706.6083,1183.3245,13.5090,268.6207 },
        { 
697.6804,1107.6698,28.1576,196.4317 },
        { 
654.5532,1046.8098,24.8911,323.3328 }
    }

But for tree positions, and a way to loop through all of them, ect. Not quite sure how I'd do that though.
Reply
#5

Код:
new Float:treePos[8][3]={
	{661.91,1289.53,10.71},
	{640.08,1289.37,10.71},
	{685.15,1257.14,10.71},
	{695.25,1231.59,10.14},
	{661.87,1190.05,10.71},
	{639.62,1190.14,9.93},
	{571.27,1256.64,10.71},
	{554.25,1242.15,10.71}
};
looks a lot better, using the previously mentioned methods, i prefer to order the numbers with leading zeros tho:
Код:
new Float:treePos[8][3]={
	{0661.9100,1289.5300,0010.7100},
	{0640.0800,1289.3700,0010.7100},
	{0685.1500,1257.1400,0010.7100},
	{0695.2500,1231.5900,0010.1400},
	{0661.8700,1190.0500,0010.7100},
	{0639.6200,1190.1400,0009.9300},
	{0571.2700,1256.6400,0010.7100},
	{0554.2500,1242.1500,0010.7100}
};
..its a bit easier to read.
the variable treeExists[] is redundant imo, if you create an object, it will never return 0 (as object id), so any created obejct will write the returned id into treeObj[], therefore you can simply check for the object existance like
Код:
if(IsValidObject(treeObj[t]))
instead using treeExists[]
hm.. i think the code can be optimized furthermore, but youll face that later (like hashing back object ids in another array, like a two-sided pointer from 1 array to another and vice versa)
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)