Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <zcmd>
- #include <streamer>
- #define dred 0xA00000FF
- forward superman(playerid);
- forward DestroyMe(objectid);
- forward Jav(playerid);
- forward Float:SetPlayerToFacePos(playerid, Float:X, Float:Y);
- forward GetClosestPlayer(p1);
- forward Float:GetDistanceBetweenPlayers(p1, p2);
- new
- bool:flying[MAX_PLAYERS],
- Javelin[MAX_PLAYERS][2],
- Float:JavPos[MAX_PLAYERS][3];
- public OnFilterScriptInit()
- {
- print("\n=======================================");
- print("\n");
- print(" SuperMan FS Loaded. ");
- print("\n");
- print("=========================================");
- return 1;
- }
- public OnFilterScriptExit()
- {
- print("________________________________________");
- return 1;
- }
- stock AngleInRangeOfAngle(Float:a1, Float:a2, Float:range)
- {
- a1 -= a2;
- if((a1 < range) && (a1 > -range)) return true;
- return false;
- }
- CMD:superman(playerid,params[])
- {
- if((flying[playerid] = !flying[playerid]))
- {
- new Float:x, Float:y, Float:z;
- GetPlayerPos(playerid, x, y, z);
- SetPlayerHealth(playerid, 1000000000.0);
- SetPlayerArmour(playerid, 1000000000.0);
- SetTimerEx("superman", 100, 0, "d", playerid);
- SetTimerEx("DestroyMe", 500, 0, "d", CreateDynamicObject(2780, x, y, z - 3.0, 0.0, 0.0, 0.0));
- }
- SetPlayerHealth(playerid, 100.0);
- SetPlayerArmour(playerid, 100.0);
- return 1;
- }
- stock IsPlayerFacingPlayer(playerid, targetid, Float:dOffset)
- {
- new
- Float:pX,
- Float:pY,
- Float:pZ,
- Float:pA,
- Float:X,
- Float:Y,
- Float:Z,
- Float:ang;
- if(!IsPlayerConnected(playerid) || !IsPlayerConnected(targetid)) return 0;
- GetPlayerPos(targetid, pX, pY, pZ);
- GetPlayerPos(playerid, X, Y, Z);
- GetPlayerFacingAngle(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);
- return AngleInRangeOfAngle(-ang, pA, dOffset);
- }
- public superman(playerid)
- {
- if(!IsPlayerConnected(playerid))
- return flying[playerid] = false;
- if(flying[playerid])
- {
- if(!IsPlayerInAnyVehicle(playerid))
- {
- new
- i,
- keys,
- ud,
- lr,
- Float:x[2],
- Float:y[2],
- Float:z,
- Float:a;
- GetPlayerKeys(playerid, keys, ud, lr);
- GetPlayerVelocity(playerid, x[0], y[0], z);
- if(!GetPlayerWeapon(playerid))
- {
- if((keys & KEY_FIRE) == (KEY_FIRE))
- {
- i = 0;
- while(i < MAX_PLAYERS)
- {
- if(i != playerid)
- {
- GetPlayerPos(i, x[0], y[0], z);
- if(IsPlayerInRangeOfPoint(playerid, 3.0, x[0], y[0], z))
- if(IsPlayerFacingPlayer(playerid, i, 15.0))
- SetPlayerVelocity(i, floatsin(-a, degrees), floatcos(-a, degrees), 0.05);
- }
- ++i;
- }
- }
- if((keys & 136) == (136))
- Jav(playerid);
- }
- if(ud == KEY_UP)
- {
- GetPlayerCameraPos(playerid, x[0], y[0], z);
- GetPlayerCameraFrontVector(playerid, x[1], y[1], z);
- a = SetPlayerToFacePos(playerid, x[0] + x[1], y[0] + y[1]);
- ApplyAnimation(playerid, "PARACHUTE", "FALL_SkyDive_Accel", 4.1, 0, 0, 0, 0, 0);
- SetPlayerVelocity(playerid, x[1], y[1], z);
- i = 0;
- while(i < MAX_PLAYERS)
- {
- if(i != playerid)
- {
- GetPlayerPos(i, x[0], y[0], z);
- if(IsPlayerInRangeOfPoint(playerid, 10.0, x[0], y[0], z))
- if(IsPlayerInAnyVehicle(i))
- {
- SetVehicleHealth(GetPlayerVehicleID(i), 0.0);
- CreateExplosion(x[0], y[0], z, 7, 5.0);
- }
- }
- ++i;
- }
- }
- else
- SetPlayerVelocity(playerid, 0.0, 0.0, 0.01);
- }
- SetTimerEx("superman", 100, 0, "d", playerid);
- }
- return 0;
- }
- public DestroyMe(objectid)
- {
- return DestroyObject(objectid);
- }
- public Jav(playerid)
- {
- if(!Javelin[playerid][1])
- {
- new
- target = GetClosestPlayer(playerid);
- if(target != -1)
- {
- GetPlayerPos(target, JavPos[playerid][0], JavPos[playerid][1], JavPos[playerid][2]);
- if(IsPlayerInRangeOfPoint(playerid, 500.0, JavPos[playerid][0], JavPos[playerid][1], JavPos[playerid][2]))
- {
- new Float:a;
- GetPlayerPos(playerid, JavPos[playerid][0], JavPos[playerid][1], JavPos[playerid][2]);
- GetPlayerFacingAngle(playerid, a);
- Javelin[playerid][0] = CreateDynamicObject(354, JavPos[playerid][0], JavPos[playerid][1], JavPos[playerid][2], 0.0, 90.0, 0.0);
- MoveObject(Javelin[playerid][0], JavPos[playerid][0], JavPos[playerid][1], JavPos[playerid][2] + 100.0, 45.0);
- GetPlayerPos(target, JavPos[playerid][0], JavPos[playerid][1], JavPos[playerid][2]);
- Javelin[playerid][1] = 1;
- }
- }
- }
- return 0;
- }
- public Float:SetPlayerToFacePos(playerid, Float:X, Float:Y)
- {
- new
- Float:pX,
- Float:pY,
- Float:pZ,
- Float:ang;
- if(!IsPlayerConnected(playerid)) return 0.0;
- GetPlayerPos(playerid, pX, pY, pZ);
- 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(X > pX) ang = (floatabs(floatabs(ang) + 180.0));
- else ang = (floatabs(ang) - 180.0);
- ang += 180.0;
- SetPlayerFacingAngle(playerid, ang);
- return ang;
- }
- public GetClosestPlayer(p1)
- {
- new
- x,
- Float:dis,
- Float:dis2,
- player;
- player = -1;
- dis = 99999.99;
- for (x=0;x<MAX_PLAYERS;x++)
- if(IsPlayerConnected(x))
- if(x != p1)
- {
- dis2 = GetDistanceBetweenPlayers(x,p1);
- if(dis2 < dis && dis2 != -1.00)
- {
- dis = dis2;
- player = x;
- }
- }
- return player;
- }
- public Float:GetDistanceBetweenPlayers(p1, p2)
- {
- new
- Float:x1,
- Float:y1,
- Float:z1,
- Float:x2,
- Float:y2,
- Float:z2;
- if(!IsPlayerConnected(p1) || !IsPlayerConnected(p2))
- return -1.00;
- GetPlayerPos(p1,x1,y1,z1);
- GetPlayerPos(p2,x2,y2,z2);
- return floatsqroot(
- floatpower(floatabs(floatsub(x2,x1)), 2)
- + floatpower(floatabs(floatsub(y2,y1)), 2)
- + floatpower(floatabs(floatsub(z2,z1)), 2));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement