SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Filterscripts > Includes

Reply
 
Thread Tools Display Modes
Old 12/07/2016, 03:42 PM   #231
VincenzoDrift
Little Clucker
 
VincenzoDrift's Avatar
 
Join Date: Jun 2014
Posts: 39
Reputation: 2
Default Re: [alpha] Objects Physics - Handle objects collisions and more.

Hi, i'm trying to make a basic drop/loot system with ColAndreas and this include. I used Peppe's example to make a function that creates an onbject to throw. If I use the function CreateObject (native) it works perfectly, but if use the streamer of ColAndreas or Incognito's streamer the object spawns, but it doesn't move. I need to use streamer due to objects limit. Any solution?
Code:
public DropInventoryItem(playerid, modelid)
{
	#define SPEED 	(10.0)
	#define Z_SPEED (4.0)
	#define GRAVITY (13.0)
	
        new Float:posx, Float:posy, Float:posz, Float:posa;		
	GetPlayerPos(playerid, posx, posy, posz);
	GetPlayerFacingAngle(playerid, posa);
		
	Streamer_Update(playerid);
	new obj = CA_CreateDynamicObject_DC(modelid, posx, posy - 0.5 * floatcos(-(posa + 90.0), degrees), posz, 93.7, 120.0, posa + 60.0, -1, -1, -1, 300.0, 300.0);
		
	PHY_InitObject();
	PHY_UseColAndreas(obj, 1);
	PHY_SetObjectVelocity(obj, SPEED * floatsin(-posa, degrees), SPEED * floatcos(-posa, degrees), Z_SPEED);
	PHY_SetObjectFriction(obj, 100);
	PHY_SetObjectGravity(obj, GRAVITY);
	ApplyAnimation(playerid, "GRENADE", "WEAPON_throwu", 3.0, 0, 0, 0, 0, 0);
	return 1;
}
__________________
Sorry for my bad english
VincenzoDrift is offline   Reply With Quote
Old 12/07/2016, 07:40 PM   #232
Crayder
High-roller
 
Crayder's Avatar
 
Join Date: Sep 2013
Location: Flames of Hell
Posts: 3,867
Reputation: 570
Default Re: [alpha] Objects Physics - Handle objects collisions and more.

Quote:
Originally Posted by VincenzoDrift View Post
Hi, i'm trying to make a basic drop/loot system with ColAndreas and this include. I used Peppe's example to make a function that creates an onbject to throw. If I use the function CreateObject (native) it works perfectly, but if use the streamer of ColAndreas or Incognito's streamer the object spawns, but it doesn't move. I need to use streamer due to objects limit. Any solution?
Code:
public DropInventoryItem(playerid, modelid)
{
	#define SPEED 	(10.0)
	#define Z_SPEED (4.0)
	#define GRAVITY (13.0)
	
        new Float:posx, Float:posy, Float:posz, Float:posa;		
	GetPlayerPos(playerid, posx, posy, posz);
	GetPlayerFacingAngle(playerid, posa);
		
	Streamer_Update(playerid);
	new obj = CA_CreateDynamicObject_DC(modelid, posx, posy - 0.5 * floatcos(-(posa + 90.0), degrees), posz, 93.7, 120.0, posa + 60.0, -1, -1, -1, 300.0, 300.0);
		
	PHY_InitObject();
	PHY_UseColAndreas(obj, 1);
	PHY_SetObjectVelocity(obj, SPEED * floatsin(-posa, degrees), SPEED * floatcos(-posa, degrees), Z_SPEED);
	PHY_SetObjectFriction(obj, 100);
	PHY_SetObjectGravity(obj, GRAVITY);
	ApplyAnimation(playerid, "GRENADE", "WEAPON_throwu", 3.0, 0, 0, 0, 0, 0);
	return 1;
}
You could just use CreateObject for these temporarily. Don't use the CA dynamic objects. Plus, there is a callback in this include for when objects collide with the CA world.

Use CreateObject.
Activate it's physics.
Wait for the world collided callback.
Get the objects information and add the drop.
Add the streamer object.
Destroy the object.
Deactivate it's physics.
__________________
Those who deserve reputation, do not need to beg for it.
Also, don't expect the help you need when offering reputation, you'll just be attracting Rep Hunters.
Join SA-MP Discord!
Crayder is offline   Reply With Quote
Old 13/07/2016, 12:59 PM   #233
VincenzoDrift
Little Clucker
 
VincenzoDrift's Avatar
 
Join Date: Jun 2014
Posts: 39
Reputation: 2
Default Re: [alpha] Objects Physics - Handle objects collisions and more.

Thanks a lot
__________________
Sorry for my bad english
VincenzoDrift is offline   Reply With Quote
Old 16/11/2016, 01:15 PM   #234
MerryDeer
Banned
 
Join Date: Jun 2016
Posts: 727
Reputation: 8
Default Re: [alpha] Objects Physics - Handle objects collisions and more.

How to make psysic object follow player and will by bouncing? it's for basketball system
MerryDeer is offline   Reply With Quote
Old 19/11/2016, 11:58 PM   #235
GoldenLion
Gangsta
 
GoldenLion's Avatar
 
Join Date: Sep 2014
Location: Estonia
Posts: 962
Reputation: 129
Default Re: [alpha] Objects Physics - Handle objects collisions and more.

Quote:
Originally Posted by Billpilot View Post
Looks nice!
Lmao, are you posting in literally every thread saying it's nice just to get post count? For example if you scroll through the gamemodes page you can see that in almost every thread the last post was made by you.
GoldenLion is offline   Reply With Quote
Old 03/11/2017, 02:55 PM   #236
bboytimix
Big Clucker
 
bboytimix's Avatar
 
Join Date: Sep 2010
Posts: 98
Reputation: 0
Default Re: [alpha] Objects Physics - Handle objects collisions and more.

just used the weapon's example

Quote:
Code:
command(launch, playerid, params[])
{
	#define SPEED (10.0)
	#define Z_SPEED (4.0)
	#define GRAVITY (13.0)
        new modelid = 348; // Deagle Model ID
	new Float:x, Float:y, Float:z, Float:ang;
	GetPlayerPos(playerid, x, y, z);
	GetPlayerFacingAngle(playerid, ang);
	new obj = CreateObject(modelid, x, y - 0.5 * floatcos(-(ang + 90.0), degrees), z, 93.7, 120.0, ang + 60.0);
 	PHY_InitObject(obj);
	PHY_SetObjectVelocity(obj, SPEED * floatsin(-ang, degrees), SPEED * floatcos(-ang, degrees), Z_SPEED);
	PHY_SetObjectFriction(obj, 100); // This will stop the object when it touchs the ground.
	PHY_SetObjectGravity(obj, GRAVITY);
	PHY_SetObjectZBound(obj, z - 1.0, _, 0.0);
	ApplyAnimation(playerid,"GRENADE","WEAPON_throwu",3.0,0,0,0,0,0);
	return 1;
}
the problem is i cant detect the current object pos its not correct
for example when im throwing the weapon ,to grab the weapon i should go to where i throw the object not to the object so i dont have idea to detect the real postion of the thrown object
any ideas ? please +REP
edited also the object not detection the ground when i throw from some roof the object stuck on the air
__________________
im Fine
bboytimix 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
Player Camera Goes Trough Objects And Attached Objects. [WSF]ThA_Devil Scripting Help 1 20/11/2013 03:40 PM
Handle multiple objects. HeLiOn_PrImE Scripting Help 5 08/04/2012 07:32 AM
If I create the objects in virtual worlds that makes room for other objects? tal_peretz Help Archive 8 17/05/2011 02:48 PM
Question regarding objects, collisions Biesmen Help Archive 5 25/03/2011 07:27 AM
Making objects, deleting created objects KnooL Help Archive 1 15/02/2009 09:34 AM


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


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