SA-MP Forums Archive
[FilterScript] [FS] Spikes ~ Create Realistic Road Spikes! - 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: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+--- Thread: [FilterScript] [FS] Spikes ~ Create Realistic Road Spikes! (/showthread.php?tid=136901)



[FS] Spikes ~ Create Realistic Road Spikes! - V1ceC1ty - 27.03.2010

Spikes
What does it do?
With a simple press of a button of your choice(default 'C') you can place realistic road Spikes where ever you want.
Also includes an automatic spike destroy timer at 60 seconds so theres not spikes placed everywhere, and also anti-spike spam so people can only place one spike each every 60 seconds.


Video
Not the best filming but I did it controlling the players both at the same time.


How to use
Download the file(below).
Extract and paste the .amx into your filterscripts folder.
Add 'Spikes' to your server.cfg

Editing the Spike key/Destroy time:
Find these two lines in the FS
pawn Code:
#define DestroyTime 60000
#define MAKESPIKE KEY_CROUCH
Change the "KEY_CROUCH" to your choice of player key. https://sampwiki.blast.hk/wiki/GetPlayerKeys#Key_List one of these.
Change the 60000 to your choice of time in ms. 1000 = 1 second, 10000 = 10 seconds etcetera.

Download

http://www.solidfiles.com/d/h5T6/

Bugs
Only know of some compiling bugs which are 3 tag mismatches on the UpdateVehicleDamageStatus line, but works perfectly fine.
Not a bug but just a heads up, the message "Spikes Placed!" will come up twice if you leave the key as 'C' because you press it twice to stand up.
Any more bugs please reply I'll try fix them


Re: [FS] Spikes ~ Create Realistic Road Spikes! - JPs_ - 27.03.2010

Nice


Re: [FS] Spikes ~ Create Realistic Road Spikes! - Joe Staff - 27.03.2010

What if someone drives into it backwards?


Re: [FS] Spikes ~ Create Realistic Road Spikes! - V1ceC1ty - 27.03.2010

Quote:
Originally Posted by Joe Staff
What if someone drives into it backwards?
Then that's a problem, I didn't want to pop all the cars tires because it will make it hard to drive but also because most people will drive forward.


Re: [FS] Spikes ~ Create Realistic Road Spikes! - Joe Staff - 27.03.2010

Quote:
Originally Posted by V1ceC1ty
... most people will drive forward.
Well I'm not most people! MWAHAHA *Drives around town backwards*



You could also determine if the player is driving backwards by checking their velocity in relation to their angle.


Re: [FS] Spikes ~ Create Realistic Road Spikes! - Las Venturas CNR - 27.03.2010

Wow This is really nice, great job, I am definetly using this.


Re: [FS] Spikes ~ Create Realistic Road Spikes! - Tannz0rz - 27.03.2010

Here Vice, just took it from my a_angles include and messed around with it a bit:

Code:
stock IsPlayerVehicleFacingPos(playerid, Float:pX, Float:pY, Float:dOffset)
{

	new
		Float:pA,
		Float:X,
		Float:Y,
		Float:Z,
		Float:ang;

	if(!IsPlayerConnected(playerid) || !GetPlayerState(playerid) != 2) return false;

	GetVehiclePos(GetPlayerVehicleID(playerid), X, Y, Z);
	GetVehicleZAngle(GetPlayerVehicleID(playerid), pA);

	if( Y > pY ) ang = (-acos((X - pX) / floatsqroot((X - pX)*(X - pX) + (Y - pY)*(Y - pY))) - 90.0);
	else if( Y < pY && X < pX ) ang = (acos((X - pX) / floatsqroot((X - pX)*(X - pX) + (Y - pY)*(Y - pY))) - 450.0);
	else if( Y < pY ) ang = (acos((X - pX) / floatsqroot((X - pX)*(X - pX) + (Y - pY)*(Y - pY))) - 90.0);

	if(AngleInRangeOfAngle(-ang, pA, dOffset)) return true;

	return false;

}

stock AngleInRangeOfAngle(Float:a1, Float:a2, Float:range)
{
	a1 -= a2;
	if((a1 < range) && (a1 > -range)) return true;

	return false;
}
Just use it in this fashion:
Code:
if(IsPlayerVehicleFacingPos(playerid, x, y, 180.0))
{
// pop front tires
}
else
{
// pop back tires
}
Or do what Joe said and just check their vehicle's velocity.


Re: [FS] Spikes ~ Create Realistic Road Spikes! - V1ceC1ty - 27.03.2010

Quote:
Originally Posted by Tannz0rz
Here Vice, just took it from my a_angles include and messed around with it a bit:
Might update it later thanks


Re: [FS] Spikes ~ Create Realistic Road Spikes! - Postalityjr - 27.03.2010

Nice script ill check it out