SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 01/03/2016, 07:20 PM   #1
Crystallize
Banned
 
Join Date: Aug 2013
Posts: 1,498
Reputation: 314
Default Help ColAndreas

I use this.
Code:
forward DestroyBlood(objectid);
public DestroyBlood(objectid)
{
	DestroyDynamicObject(objectid);
}
stock CreateGroundBlood(playerid)
{
	new Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz;
	GetPlayerPos(playerid, x, y, z);

	if(CA_RayCastLineAngle(x, y, z, x, y, z - 2.0, x, y, z, rx, ry, rz))
	return SetTimerEx("DestroyBlood", 1500, false, "d", CreateDynamicObject(19836, x, y, z, rx, ry, rz)), 1;

	return 0;
}
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
	
	if(hittype == BULLET_HIT_TYPE_PLAYER) 
{
		new Float:sx, Float:sy, Float:sz,
			Float:rx, Float:ry, Float:rz;

		GetPlayerCameraPos(playerid, sx, sy, sz);

		new Float:x = fX - sx,
			Float:y = fY - sy,
			Float:z = fZ - sz;

		new Float:d = VectorSize(x, y, z);
		x /= d;
		y /= d;
		z /= d;

		x *= 10.0;
		y *= 10.0;
		z *= 10.0;

		if(CA_RayCastLineAngle(fX, fY, fZ, fX + x, fY + y, fZ + z, x, y, z, rx, ry, rz))
		SetTimerEx("DestroyBlood", 1500, false, "d", CreateDynamicObject(19836, x, y, z, rx, ry, rz));
	}
	return 1;
}
public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid, bodypart)
{
CreateGroundBlood(playerid);
return 1;
}
There is blood on the ground but not in the wall as supposed to , what is wrong with this code? I have never worked with ColAndreas before any help is appreciated!
Crystallize is offline   Reply With Quote
Old 01/03/2016, 07:46 PM   #2
[NWA]Hannes
Huge Clucker
 
[NWA]Hannes's Avatar
 
Join Date: Jul 2010
Location: Sweden
Posts: 341
Reputation: 12
Default Re: Help ColAndreas

You have static values for where the blood object is supposed to be created and I don't think the script can know the distance to the closest wall in order to create the blood on it.
__________________
Mostly inactive.

My old account is bajskorv123. (Now I have a low post count)
[NWA]Hannes is offline   Reply With Quote
Old 01/03/2016, 07:54 PM   #3
Crystallize
Banned
 
Join Date: Aug 2013
Posts: 1,498
Reputation: 314
Default Re: Help ColAndreas

Quote:
Originally Posted by [NWA]Hannes View Post
You have static values for where the blood object is supposed to be created and I don't think the script can know the distance to the closest wall in order to create the blood on it.
That's why I use ColAndreas and the RayCastLineAngle function?
Crystallize is offline   Reply With Quote
Old 01/03/2016, 08:04 PM   #4
[NWA]Hannes
Huge Clucker
 
[NWA]Hannes's Avatar
 
Join Date: Jul 2010
Location: Sweden
Posts: 341
Reputation: 12
Default Re: Help ColAndreas

Quote:
Originally Posted by Wizzard2H View Post
That's why I use ColAndreas and the RayCastLineAngle function?
As I said, I've never used the plugin, it was just a mere suggestion to why your script might not have been working properly. Perhaps RayCastLineAngle does not work for custom wall objects if that what you're using, apologies for trying to help you with your problem.
__________________
Mostly inactive.

My old account is bajskorv123. (Now I have a low post count)
[NWA]Hannes is offline   Reply With Quote
Old 01/03/2016, 09:25 PM   #5
Nero_3D
High-roller
 
Nero_3D's Avatar
 
Join Date: Jun 2007
Location: Germany
Posts: 2,852
Reputation: 675
Default Re: Help ColAndreas

fX, fY and fZ are offsets and not the target position
Anyways for the weapon pos you need GetPlayerLastShotVectors
PHP Code:
// OnPlayerWeaponShot
    
if(hittype == BULLET_HIT_TYPE_PLAYER
    {
        new
            
FloatvX,
            
FloatvY,
            
FloatvZ
        
;
        
GetPlayerLastShotVectors(playeridvXvYvZfXfYfZ);

        
vX fX vX;
        
vY fY vY;
        
vZ fZ vZ;

        (
Floathittype) = 5.0 VectorSize(vXvYvZ);

        
vX *= Floathittype;
        
vY *= Floathittype;
        
vZ *= Floathittype;

        if(
CA_RayCastLineAngle(fXfYfZfX vXfY vYfZ vZvXvYvZfXfYfZ))
            
SetTimerEx("DestroyBlood"1500false"d"CreateDynamicObject(19836vXvYvZfXfYfZ));
    } 
Nero_3D is online now   Reply With Quote
Old 01/03/2016, 09:45 PM   #6
Crayder
Banned
 
Join Date: Sep 2013
Location: Flames of Hell
Posts: 3,324
Reputation: 652
Default Re: Help ColAndreas

@Nero_3D: Yeah when I wrote that code I forgot 'f' was offsets... xD

Basically what I was doing was calculating the unit vector with it and the camera position.

Now... Why are you dividing 5 by the distance...? I'm confused...
Crayder is offline   Reply With Quote
Old 01/03/2016, 09:58 PM   #7
Nero_3D
High-roller
 
Nero_3D's Avatar
 
Join Date: Jun 2007
Location: Germany
Posts: 2,852
Reputation: 675
Default Re: Help ColAndreas

Quote:
Originally Posted by Crayder View Post
@Nero_3D: Yeah when I wrote that code I forgot 'f' was offsets... xD

Basically what I was doing was calculating the unit vector with it and the camera position.

Now... Why are you dividing 5 by the distance...? I'm confused...
Normalization and multiplied by 5, pretty much the same as
Quote:
Originally Posted by Wizzard2H View Post
Code:
		new Float:d = VectorSize(x, y, z);
		x /= d;
		y /= d;
		z /= d;

		x *= 10.0;
		y *= 10.0;
		z *= 10.0;
Nero_3D is online now   Reply With Quote
Old 02/03/2016, 03:53 AM   #8
Crayder
Banned
 
Join Date: Sep 2013
Location: Flames of Hell
Posts: 3,324
Reputation: 652
Default Re: Help ColAndreas

Updated the code in the useful functions thread.

Thanks Wizzard2H for pointing out that it was failing. As noted there, I hadn't tested it before posting it.
Crayder 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
Fail ColAndreas OrangeJam Русский/Russian 1 15/02/2016 04:47 AM
[Plugin] ColAndreas - (Released) Pottus Plugin Development 415 19/08/2015 12:31 AM
[Off] ColAndreas - Qual Sua Utilidade ?? Holl Portuguкs/Portuguese 3 09/06/2015 03:27 PM


All times are GMT. The time now is 05:59 PM.


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