SA-MP Forums Archive
Lumberjack help, I have a headache. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Lumberjack help, I have a headache. (/showthread.php?tid=664069)



Lumberjack help, I have a headache. - MyUndiesSmell - 18.02.2019

Код:
new LumberJackTree[15];

public OnPlayerConnect(playerid)
{
	LumberJackTree[0] = CreateObject(892, -497.446624, -62.991870, 60.289428, 0.000000, 0.000000, 0.000000, 300.00); 
    	LumberJackTree[1] = CreateObject(892, -488.650482, -62.737354, 59.973289, 0.000000, 0.000000, 0.000000, 300.00); 
   	LumberJackTree[2] = CreateObject(892, -480.929779, -63.083427, 59.659553, 0.000000, 0.000000, 0.000000, 300.00); 
    	LumberJackTree[3] = CreateObject(892, -473.068786, -63.282073, 59.345729, 0.000000, 0.000000, 0.000000, 300.00); 
   	LumberJackTree[4] = CreateObject(892, -464.964324, -64.386199, 59.087421, 0.000000, 0.000000, 0.000000, 300.00); 
    	LumberJackTree[5] = CreateObject(892, -461.846618, -54.567378, 59.043685, 0.000000, 0.000000, 0.000000, 300.00); 
    	LumberJackTree[6] = CreateObject(892, -470.528350, -52.936355, 59.151813, 0.000000, 0.000000, 0.000000, 300.00); 
    	LumberJackTree[7] = CreateObject(892, -478.066589, -52.890533, 59.265464, 0.000000, 0.000000, 0.000000, 300.00); 
    	LumberJackTree[8] = CreateObject(892, -487.057525, -52.328693, 59.463527, 0.000000, 0.000000, 0.000000, 300.00); 
    	LumberJackTree[9] = CreateObject(892, -496.125122, -52.100967, 59.372920, 0.000000, 0.000000, 0.000000, 300.00); 
    	LumberJackTree[10] = CreateObject(892, -494.526092, -39.977500, 59.277206, 0.000000, 0.000000, 0.000000, 300.00); 
    	LumberJackTree[11] = CreateObject(892, -485.614471, -40.435729, 59.019008, 0.000000, 0.000000, 0.000000, 300.00); 
    	LumberJackTree[12] = CreateObject(892, -478.597869, -40.759445, 58.994010, 0.000000, 0.000000, 0.000000, 300.00); 
    	LumberJackTree[13] = CreateObject(892, -470.518829, -39.444923, 58.971988, 0.000000, 0.000000, 0.000000, 300.00); 
    	LumberJackTree[14] = CreateObject(892, -461.466094, -38.041519, 58.947326, 0.000000, 0.000000, 0.000000, 300.00);
	return 1;
}

TreeToPlayerDistance(playerid, Float: range = 2.0)
{
    new Float:Distance = range; 
    new Float:tx, Float:ty, Float: tz;

    for(new i = 0; i < sizeof(LumberJackTree); i++)
    {
        GetObjectPos(LumberJackTree[i], tx, ty, tz);
    }

    Distance = GetPlayerDistanceFromPoint(playerid, tx, ty, tz);
    if(Distance > range)
    {
        SendClientMessage(playerid, -1, "near tree");
    }
    else return SendClientMessage(playerid, -1, "not near tree");
    return 1;
}

CMD:test(playerid, params[])
{
	TreeToPlayerDistance(playerid);
	return 1;
}



Re: Lumberjack help, I have a headache. - Kasichok - 18.02.2019

PHP код:
TreeToPlayerDistance(playeridFloatrange)
{
    new 
Float:Distance;
    new 
Float:txFloat:tyFloattz;
    for(new 
0sizeof(LumberJackTree); i++)
    {
        
GetObjectPos(LumberJackTree[i], txtytz);
        
Distance GetPlayerDistanceFromPoint(playeridtxtytz);
        if(
Distance range)
        {
            return 
SendClientMessage(playerid, -1"near tree");
        }
    }
    return 
SendClientMessage(playerid, -1"not near tree");
}
CMD:test(playeridparams[])
{
    
TreeToPlayerDistance(playerid2.0);
    return 
1;




Re: Lumberjack help, I have a headache. - MyUndiesSmell - 18.02.2019

Quote:
Originally Posted by Kasichok
Посмотреть сообщение
PHP код:
TreeToPlayerDistance(playeridFloatrange)
{
    new 
Float:Distance;
    new 
Float:txFloat:tyFloattz;
    for(new 
0sizeof(LumberJackTree); i++)
    {
        
GetObjectPos(LumberJackTree[i], txtytz);
        
Distance GetPlayerDistanceFromPoint(playeridtxtytz);
        if(
Distance range)
        {
            return 
SendClientMessage(playerid, -1"near tree");
        }
    }
    return 
SendClientMessage(playerid, -1"not near tree");
}
CMD:test(playeridparams[])
{
    
TreeToPlayerDistance(playerid2.0);
    return 
1;

Will test when home thanks


Re: Lumberjack help, I have a headache. - MyUndiesSmell - 18.02.2019

Works thank you. Repped you btw.


Re: Lumberjack help, I have a headache. - Pottus - 18.02.2019

Why are you doing this?
Код:
public OnPlayerConnect(playerid)
{
	LumberJackTree[0] = CreateObject(892, -497.446624, -62.991870, 60.289428, 0.000000, 0.000000, 0.000000, 300.00); 
    	LumberJackTree[1] = CreateObject(892, -488.650482, -62.737354, 59.973289, 0.000000, 0.000000, 0.000000, 300.00); 
   	LumberJackTree[2] = CreateObject(892, -480.929779, -63.083427, 59.659553, 0.000000, 0.000000, 0.000000, 300.00); 
    	LumberJackTree[3] = CreateObject(892, -473.068786, -63.282073, 59.345729, 0.000000, 0.000000, 0.000000, 300.00); 
   	LumberJackTree[4] = CreateObject(892, -464.964324, -64.386199, 59.087421, 0.000000, 0.000000, 0.000000, 300.00); 
    	LumberJackTree[5] = CreateObject(892, -461.846618, -54.567378, 59.043685, 0.000000, 0.000000, 0.000000, 300.00); 
    	LumberJackTree[6] = CreateObject(892, -470.528350, -52.936355, 59.151813, 0.000000, 0.000000, 0.000000, 300.00); 
    	LumberJackTree[7] = CreateObject(892, -478.066589, -52.890533, 59.265464, 0.000000, 0.000000, 0.000000, 300.00); 
    	LumberJackTree[8] = CreateObject(892, -487.057525, -52.328693, 59.463527, 0.000000, 0.000000, 0.000000, 300.00); 
    	LumberJackTree[9] = CreateObject(892, -496.125122, -52.100967, 59.372920, 0.000000, 0.000000, 0.000000, 300.00); 
    	LumberJackTree[10] = CreateObject(892, -494.526092, -39.977500, 59.277206, 0.000000, 0.000000, 0.000000, 300.00); 
    	LumberJackTree[11] = CreateObject(892, -485.614471, -40.435729, 59.019008, 0.000000, 0.000000, 0.000000, 300.00); 
    	LumberJackTree[12] = CreateObject(892, -478.597869, -40.759445, 58.994010, 0.000000, 0.000000, 0.000000, 300.00); 
    	LumberJackTree[13] = CreateObject(892, -470.518829, -39.444923, 58.971988, 0.000000, 0.000000, 0.000000, 300.00); 
    	LumberJackTree[14] = CreateObject(892, -461.466094, -38.041519, 58.947326, 0.000000, 0.000000, 0.000000, 300.00);
	return 1;
}



Re: Lumberjack help, I have a headache. - TheToretto - 18.02.2019

Put the code under OnGameModeInit or OnFilterScriptInit, not OnPlayerConnect


Re: Lumberjack help, I have a headache. - MyUndiesSmell - 19.02.2019

Quote:
Originally Posted by Pottus
Посмотреть сообщение
Why are you doing this?
Код:
public OnPlayerConnect(playerid)
{
	LumberJackTree[0] = CreateObject(892, -497.446624, -62.991870, 60.289428, 0.000000, 0.000000, 0.000000, 300.00); 
    	LumberJackTree[1] = CreateObject(892, -488.650482, -62.737354, 59.973289, 0.000000, 0.000000, 0.000000, 300.00); 
   	LumberJackTree[2] = CreateObject(892, -480.929779, -63.083427, 59.659553, 0.000000, 0.000000, 0.000000, 300.00); 
    	LumberJackTree[3] = CreateObject(892, -473.068786, -63.282073, 59.345729, 0.000000, 0.000000, 0.000000, 300.00); 
   	LumberJackTree[4] = CreateObject(892, -464.964324, -64.386199, 59.087421, 0.000000, 0.000000, 0.000000, 300.00); 
    	LumberJackTree[5] = CreateObject(892, -461.846618, -54.567378, 59.043685, 0.000000, 0.000000, 0.000000, 300.00); 
    	LumberJackTree[6] = CreateObject(892, -470.528350, -52.936355, 59.151813, 0.000000, 0.000000, 0.000000, 300.00); 
    	LumberJackTree[7] = CreateObject(892, -478.066589, -52.890533, 59.265464, 0.000000, 0.000000, 0.000000, 300.00); 
    	LumberJackTree[8] = CreateObject(892, -487.057525, -52.328693, 59.463527, 0.000000, 0.000000, 0.000000, 300.00); 
    	LumberJackTree[9] = CreateObject(892, -496.125122, -52.100967, 59.372920, 0.000000, 0.000000, 0.000000, 300.00); 
    	LumberJackTree[10] = CreateObject(892, -494.526092, -39.977500, 59.277206, 0.000000, 0.000000, 0.000000, 300.00); 
    	LumberJackTree[11] = CreateObject(892, -485.614471, -40.435729, 59.019008, 0.000000, 0.000000, 0.000000, 300.00); 
    	LumberJackTree[12] = CreateObject(892, -478.597869, -40.759445, 58.994010, 0.000000, 0.000000, 0.000000, 300.00); 
    	LumberJackTree[13] = CreateObject(892, -470.518829, -39.444923, 58.971988, 0.000000, 0.000000, 0.000000, 300.00); 
    	LumberJackTree[14] = CreateObject(892, -461.466094, -38.041519, 58.947326, 0.000000, 0.000000, 0.000000, 300.00);
	return 1;
}
I know I realized after the fact. I was more worried about getting the distance to work. dont want x1000 objects lmao


Re: Lumberjack help, I have a headache. - MyUndiesSmell - 19.02.2019

Код:
public OnGameModeInit()
{
	LumberJackTree[0] = CreateObject(892, -497.446624, -62.991870, 60.289428, 0.000000, 0.000000, 0.000000, 300.00);
	LumberJackTree[1] = CreateObject(892, -488.650482, -62.737354, 59.973289, 0.000000, 0.000000, 0.000000, 300.00); 
	LumberJackTree[2] = CreateObject(892, -480.929779, -63.083427, 59.659553, 0.000000, 0.000000, 0.000000, 300.00); 
	LumberJackTree[3] = CreateObject(892, -473.068786, -63.282073, 59.345729, 0.000000, 0.000000, 0.000000, 300.00); 
	LumberJackTree[4] = CreateObject(892, -464.964324, -64.386199, 59.087421, 0.000000, 0.000000, 0.000000, 300.00); 
	LumberJackTree[5] = CreateObject(892, -461.846618, -54.567378, 59.043685, 0.000000, 0.000000, 0.000000, 300.00); 
	LumberJackTree[6] = CreateObject(892, -470.528350, -52.936355, 59.151813, 0.000000, 0.000000, 0.000000, 300.00); 
	LumberJackTree[7] = CreateObject(892, -478.066589, -52.890533, 59.265464, 0.000000, 0.000000, 0.000000, 300.00); 
	LumberJackTree[8] = CreateObject(892, -487.057525, -52.328693, 59.463527, 0.000000, 0.000000, 0.000000, 300.00); 
	LumberJackTree[9] = CreateObject(892, -496.125122, -52.100967, 59.372920, 0.000000, 0.000000, 0.000000, 300.00); 
	LumberJackTree[10] = CreateObject(892, -494.526092, -39.977500, 59.277206, 0.000000, 0.000000, 0.000000, 300.00); 
	LumberJackTree[11] = CreateObject(892, -485.614471, -40.435729, 59.019008, 0.000000, 0.000000, 0.000000, 300.00); 
	LumberJackTree[12] = CreateObject(892, -478.597869, -40.759445, 58.994010, 0.000000, 0.000000, 0.000000, 300.00); 
	LumberJackTree[13] = CreateObject(892, -470.518829, -39.444923, 58.971988, 0.000000, 0.000000, 0.000000, 300.00); 
	LumberJackTree[14] = CreateObject(892, -461.466094, -38.041519, 58.947326, 0.000000, 0.000000, 0.000000, 300.00);
	for(new i = 0; i < sizeof(LumberJackTree); i++) 
	{
		printf("%i were created", LumberJackTree[i]);
	}	
	return 1;
}
They are creating but not appearing why?