SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 18/02/2019, 08:21 PM   #1
MyUndiesSmell
Big Clucker
 
Join Date: Sep 2015
Posts: 63
Reputation: 0
Default Lumberjack help, I have a headache.

Code:
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;
}
MyUndiesSmell is offline   Reply With Quote
Old 18/02/2019, 09:18 PM   #2
Kasichok
Big Clucker
 
Kasichok's Avatar
 
Join Date: Sep 2018
Location: weed farm
Posts: 95
Reputation: 35
Default Re: Lumberjack help, I have a headache.

PHP Code:
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;

__________________



STRESSED? TRY KASICHOK AND RELAX


Kasichok is offline   Reply With Quote
Old 18/02/2019, 10:17 PM   #3
MyUndiesSmell
Big Clucker
 
Join Date: Sep 2015
Posts: 63
Reputation: 0
Default Re: Lumberjack help, I have a headache.

Quote:
Originally Posted by Kasichok View Post
PHP Code:
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
MyUndiesSmell is offline   Reply With Quote
Old 18/02/2019, 10:53 PM   #4
MyUndiesSmell
Big Clucker
 
Join Date: Sep 2015
Posts: 63
Reputation: 0
Default Re: Lumberjack help, I have a headache.

Works thank you. Repped you btw.
MyUndiesSmell is offline   Reply With Quote
Old 18/02/2019, 11:19 PM   #5
Pottus
High-roller
 
Pottus's Avatar
 
Join Date: Jun 2012
Posts: 4,883
Reputation: 1321
Default Re: Lumberjack help, I have a headache.

Why are you doing this?
Code:
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;
}
Pottus is offline   Reply With Quote
Old 18/02/2019, 11:21 PM   #6
TheToretto
Gangsta
 
TheToretto's Avatar
 
Join Date: Jul 2015
Posts: 584
Reputation: 66
Default Re: Lumberjack help, I have a headache.

Put the code under OnGameModeInit or OnFilterScriptInit, not OnPlayerConnect
__________________






Toretto#9902

Rest in peace grandpa, 03 November 2018
TheToretto is offline   Reply With Quote
Old 19/02/2019, 01:25 AM   #7
MyUndiesSmell
Big Clucker
 
Join Date: Sep 2015
Posts: 63
Reputation: 0
Default Re: Lumberjack help, I have a headache.

Quote:
Originally Posted by Pottus View Post
Why are you doing this?
Code:
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
MyUndiesSmell is offline   Reply With Quote
Old 19/02/2019, 01:45 AM   #8
MyUndiesSmell
Big Clucker
 
Join Date: Sep 2015
Posts: 63
Reputation: 0
Default Re: Lumberjack help, I have a headache.

Code:
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?

MyUndiesSmell is offline   Reply With Quote
Reply

Thread Tools
Display Modes

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
[FilterScript] Lumberjack Job rootcause Filterscripts 56 25/01/2020 08:59 AM
[FilterScript] LumberJack Job eMapper Filterscripts 36 13/08/2017 02:51 PM
TextDraw Headache marley Scripting Help 0 16/11/2016 09:06 AM
Lumberjack Job help[rep] GeorgeMcReary Scripting Help 3 05/05/2016 12:56 PM
CreateDynamicMapIcon headache... Ash. Help Archive 8 23/04/2011 04:38 AM


All times are GMT. The time now is 03:47 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.