SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 29/05/2020, 09:13 PM   #11
zampa
Little Clucker
 
Join Date: Dec 2019
Posts: 17
Reputation: 0
Default Re: Problem MovableObjects

Try this code, worked for me.
Also if you don't have streamer plugin download it here

Code:
new lspdbarrier;

lspdbarrier = CreateDynamicObject(968, 1544.69995, -1630.80005, 13.10000,   0.00000, 90.00000, 90.00000); // closed

public InitPos()
{
	MoveDynamicObject(lspdbarrier, 1544.69995, -1630.80005, 13.10000 + 0.001, 0.00350, 0.00000, 90.00000, 90.00000);
	return 1;
}

public OnPlayerUpdate(playerid)
{
	if(IsPlayerInRangeOfPoint(playerid, 7.0, 1539.7244, -1627.6182, 13.3828))
	{
		MoveDynamicObject(lspdbarrier, 1544.69995, -1630.80005, 13.10000 - 0.001, 0.00350, 0.00000, 0.00000, 90.00000);
	    SetTimer("InitPos", 2000, false);
 	}
	return 1;
}
zampa is offline   Reply With Quote
Old 29/05/2020, 09:28 PM   #12
Nexotronix
Huge Clucker
 
Nexotronix's Avatar
 
Join Date: Jan 2010
Location: Donetsk/Ukraine
Posts: 275
Reputation: 41
Thumbs up Re: Problem MovableObjects

Quote:
Originally Posted by zampa View Post
Try this code, worked for me.
Also if you don't have streamer plugin download it here

Code:
new lspdbarrier;

lspdbarrier = CreateDynamicObject(968, 1544.69995, -1630.80005, 13.10000,   0.00000, 90.00000, 90.00000); // closed

public InitPos()
{
	MoveDynamicObject(lspdbarrier, 1544.69995, -1630.80005, 13.10000 + 0.001, 0.00350, 0.00000, 90.00000, 90.00000);
	return 1;
}

public OnPlayerUpdate(playerid)
{
	if(IsPlayerInRangeOfPoint(playerid, 7.0, 1539.7244, -1627.6182, 13.3828))
	{
		MoveDynamicObject(lspdbarrier, 1544.69995, -1630.80005, 13.10000 - 0.001, 0.00350, 0.00000, 0.00000, 90.00000);
	    SetTimer("InitPos", 2000, false);
 	}
	return 1;
}

Thatís what Iím talking about 😎 simple and works well
__________________
Work In Progress:
[GameMode]Stroberia RolePlay (20%) [Join My Channel to take part in Testing http://discord.gg/sBpRC5E]
Development Video: Watch Here
Serverside Map/GPS System: Watch Here
Discord: Tom_Strobe#2300
Nexotronix is offline   Reply With Quote
Old 29/05/2020, 09:59 PM   #13
XBRSAKOSKYX
Little Clucker
 
Join Date: Apr 2020
Posts: 34
Reputation: 0
Default Re: Problem MovableObjects

Quote:
Originally Posted by zampa View Post
Try this code, worked for me.
Also if you don't have streamer plugin download it here

Code:
new lspdbarrier;

lspdbarrier = CreateDynamicObject(968, 1544.69995, -1630.80005, 13.10000,   0.00000, 90.00000, 90.00000); // closed

public InitPos()
{
	MoveDynamicObject(lspdbarrier, 1544.69995, -1630.80005, 13.10000 + 0.001, 0.00350, 0.00000, 90.00000, 90.00000);
	return 1;
}

public OnPlayerUpdate(playerid)
{
	if(IsPlayerInRangeOfPoint(playerid, 7.0, 1539.7244, -1627.6182, 13.3828))
	{
		MoveDynamicObject(lspdbarrier, 1544.69995, -1630.80005, 13.10000 - 0.001, 0.00350, 0.00000, 0.00000, 90.00000);
	    SetTimer("InitPos", 2000, false);
 	}
	return 1;
}
Thanks guys, thank you everyone who tried to help!! Its solved now and its working <3 +rep to all
XBRSAKOSKYX is offline   Reply With Quote
Old 30/05/2020, 07:00 AM   #14
Killa[DGZ]
Huge Clucker
 
Killa[DGZ]'s Avatar
 
Join Date: Feb 2010
Location: Australia
Posts: 356
Reputation: 88
Default Re: Problem MovableObjects

NaS is right, don't use OnPlayerUpdate for this you're just shooting yourself in the foot, use a timer or OnObjectMoved.. otherwise it's just poor design and logic and will be calling that every 20ms for every player which is BAD!
__________________
Killa[DGZ] is offline   Reply With Quote
Old 30/05/2020, 09:54 AM   #15
Runn3R
Huge Clucker
 
Runn3R's Avatar
 
Join Date: Dec 2013
Location: Croatia, Split
Posts: 420
Reputation: 36
Default Re: Problem MovableObjects

Alternatively, you can use the OnPlayerEnterDynamicArea if you are using a streamer and do it like that.
Runn3R is offline   Reply With Quote
Old 30/05/2020, 11:56 AM   #16
zampa
Little Clucker
 
Join Date: Dec 2019
Posts: 17
Reputation: 0
Default Re: Problem MovableObjects

Use this code

Code:
new lspdbarrier, BarrierArea, barrierTimer;

//OnGameModeInit
lspdbarrier = CreateDynamicObject(968, 1544.69995, -1630.80005, 13.10000,   0.00000, 90.00000, 90.00000); // closed
BarrierArea = CreateDynamicSphere(1544.69995, -1630.80005, 13.10000, 7.0);

public InitPos()
{
	MoveDynamicObject(lspdbarrier, 1544.69995, -1630.80005, 13.10000 + 0.001, 0.00350, 0.00000, 90.00000, 90.00000);
	return 1;
}

public OnPlayerEnterDynamicArea(playerid, areaid)
{
	if(areaid == BarrierArea)
	{
	    KillTimer(barrierTimer);
		MoveDynamicObject(lspdbarrier, 1544.69995, -1630.80005, 13.10000 - 0.001, 0.00350, 0.00000, 0.00000, 90.00000);
	    barrierTimer = SetTimer("InitPos", 2000, false);
 	}
	return 1;
}
zampa is offline   Reply With Quote
Old 30/05/2020, 05:02 PM   #17
Runn3R
Huge Clucker
 
Runn3R's Avatar
 
Join Date: Dec 2013
Location: Croatia, Split
Posts: 420
Reputation: 36
Default Re: Problem MovableObjects

Why are you writing a code for other people? Just let them do it by themselves, jesus.
Runn3R 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
Password Hash Problem & MYSQL Saving Problem Faqahat Scripting Help 3 18/04/2016 11:54 AM
[SOLVED] 3 problem's! (1 problem still unsolved, but stopped solving.) Mechscape Help Archive 9 24/12/2009 08:47 PM


All times are GMT. The time now is 02:47 AM.


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