Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define FILTERSCRIPT
- #include <a_samp>
- #include <zcmd>
- #include <sscanf2>
- new Float: speed = 0.5; // by default
- new Float: height = 0.5;
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print(" Fus Ro Dah by myAnus");
- print("--------------------------------------\n");
- return 1;
- }
- public OnFilterScriptExit()
- {
- print("Shout unloaded.");
- return 1;
- }
- CMD:setshoutdata(playerid, params[])
- {
- new string[128];
- new dataType[20], Float: value;
- if(sscanf(params, "s[20]f", dataType, value)) return SendClientMessage(playerid, -1, "/setshoutvalue [type](speed, height) [value](float)");
- if(strcmp(dataType, "speed", true) == 0)
- {
- if(value <= 0.0) SendClientMessage(playerid, -1, "Warning: speed need to be greater than 0");
- format(string, sizeof(string), "Speed has been changed from %f to %f .", speed, value);
- speed = value;
- SendClientMessageToAll(-1, string);
- }
- else if(strcmp(dataType, "height", true) == 0)
- {
- format(string, sizeof(string), "Z velocity has been changed from %f to %f .", height, value);
- height = value;
- SendClientMessageToAll(-1, string);
- }
- else SendClientMessage(playerid, -1, "/setshoutvalue [type](speed, height) [value](float)");
- return 1;
- }
- CMD:fusrodah(playerid, params[])
- {
- new string[128], name[MAX_PLAYER_NAME + 1], bool:inVeh = false;
- GetPlayerName(playerid, name, sizeof(name));
- new Float: x, Float:y, Float:z, Float: xEx, Float: yEx;
- if(IsPlayerInAnyVehicle(playerid))
- {
- GetPlayerPos(playerid, x, y, z);
- CreateExplosion(x, y, z, 2, 10.0);
- SetPlayerHealth(playerid, 0.0);
- SendClientMessage(playerid, -1, "You shouted in a vehicle, thus creating an awesome explosion.");
- return 1;
- }
- /*if(speed < 0.0001) speed = 0.5;
- if(height < 0.0001) speed = 0.3;*/
- GetPlayerPos(playerid, x, y, z);
- GetXYInFrontOfPlayer(playerid, x, y, 5.0);
- GetXYInFrontOfPlayer(playerid, xEx, yEx, 10.0);
- /* Get velocity*
- new Float: xV, Float: yV, Float: fAngle;
- if(IsPlayerInAnyVehicle(playerid))
- {
- inVeh = true;
- GetVehicleZAngle(GetPlayerVehicleID(playerid), fAngle);
- }
- else GetPlayerFacingAngle(playerid, fAngle);
- xV = (speed * floatsin(-fAngle, degrees));
- yV = (speed * floatcos(-fAngle, degrees));
- *End here */
- SetPlayerChatBubble(playerid, "FUS RO DAH!", -1, 16, 5000);
- new Float: health;
- new Float: opX, Float: opY, Float:opZ, Float: xV, Float: yV, Float: fAngle;
- new Float: victimX, Float: victimY;
- GetPlayerPos(playerid, opX, opY, opZ);
- for(new i = 0; i < MAX_PLAYERS; i++)
- {
- if(IsPlayerConnected(i))
- {
- if(IsPlayerInRangeOfPoint(i, 5.0, x, y, z) || IsPlayerInRangeOfPoint(i, 8.0, xEx, yEx, z))
- {
- if(i != playerid)
- {
- /* New Get Velocity*/
- GetPlayerPos(i, victimX, victimY, opZ);
- fAngle = GetFacingPos(victimX, victimY, opX, opY);
- xV = (speed * floatsin(-fAngle, degrees));
- yV = (speed * floatcos(-fAngle, degrees));
- xV *= -1;
- yV *= -1;
- /* End here */
- if (IsPlayerInAnyVehicle(i)) inVeh = true;
- GetPlayerHealth(i, health);
- if(inVeh)
- {
- xV *= 0.85; //Hard coded velocity reduction, you can change it to w/e you like.
- yV *= 0.85;
- height *= 0.85;
- SetVehicleVelocity(GetPlayerVehicleID(i), xV, yV, height);
- inVeh = false;
- }
- else
- {
- health -= 2.0;
- SetPlayerVelocity(i, xV, yV, height);
- GetPlayerVelocity(i, xV, yV, opZ);
- SetPlayerHealth(i, health);
- printf("[Z Velocity Tracker] Velocity applied to: %d | Variable \"height\" : %f | Actual Velocity applied: ", i, height, opZ);
- }
- format(string, sizeof(string), "You have been FUS RO DAH'ed by %s !", name);
- SendClientMessage(i, -1, string);
- }// not the command sender
- }// range check
- }//online check
- }//close loop
- // This following was made to detect every empty vehicle, but saidly car w/o a driver cant be assigned a velocity :(
- /*new Float:distance1, Float: distance2;
- GetPlayerPos(playerid, victimX, victimY, z);
- for(new i = 0; i < 1782; i++)
- {
- if(IsVehicleEmpty(i))
- {
- GetVehiclePos(i, opX, opY, opZ);
- distance1 = floatsqroot(floatpower(floatabs(floatsub(opX,x)),2)+floatpower(floatabs(floatsub(opY,y)),2)+floatpower(floatabs(floatsub(opZ,z)),2));
- distance2 = floatsqroot(floatpower(floatabs(floatsub(opX,xEx)),2)+floatpower(floatabs(floatsub(opY,yEx)),2)+floatpower(floatabs(floatsub(opZ,z)),2));
- if(distance1 <= 5.0 || distance2 <= 8.0)
- {
- fAngle = GetFacingPos(opX, opY, victimX, victimY);
- xV = (speed * floatsin(-fAngle, degrees));
- yV = (speed * floatcos(-fAngle, degrees));
- xV *= -0.85;
- yV *= -0.85;
- SetVehicleVelocity(i, xV, yV, height);
- }//range check
- }//empty vehicle check.
- }//empty vehicle check*/
- return 1;
- }
- /*stock IsVehicleEmpty( vehicleid ) //credit to who ever made this
- {
- for ( new playerid = 0; playerid < MAX_PLAYERS; playerid++ )
- {
- if ( !IsPlayerConnected( playerid ) )
- continue;
- if ( GetPlayerVehicleID( playerid ) == vehicleid )
- return false;
- }
- return true;
- }*/
- forward Float: GetFacingPos(Float: fromX, Float: fromY, Float: x, Float: y);
- Float: GetFacingPos(Float: fromX, Float: fromY, Float:x, Float:y)//http://forum.sa-mp.com/showthread.php?t=38965&page=338
- {
- new Float:angle;
- new Float:misc = 5.0;
- angle = 180.0-atan2(fromX-x,fromY-y);
- angle += misc;
- misc *= -1;
- angle += misc;
- return angle;
- }
- GetXYInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance)
- {
- // Credit: Y_Less
- new Float:a;
- GetPlayerPos(playerid, x, y, a);
- GetPlayerFacingAngle(playerid, a);
- if (GetPlayerVehicleID(playerid)) {
- GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
- }
- x += (distance * floatsin(-a, degrees));
- y += (distance * floatcos(-a, degrees));
- }
Advertisement
Add Comment
Please, Sign In to add comment