GlorifiedPig

Untitled

Jan 11th, 2018
1,000
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 4.12 KB | None | 0 0
  1. #define FILTERSCRIPT
  2.  
  3. #include <a_samp>
  4. #include <zcmd>
  5. #include <sscanf2>
  6.  
  7. public OnFilterScriptInit()
  8. {
  9.     print("\n--------------------------------------");
  10.     print(" Drone System by GlorifiedPig");
  11.     print("--------------------------------------\n");
  12.     return 1;
  13. }
  14.  
  15. public OnFilterScriptExit()
  16. {
  17.     return 1;
  18. }
  19.  
  20.  
  21. #define COLOR_GREY 0xAFAFAFAA
  22. #define COLOR_GREEN 0x33AA33AA
  23. #define COLOR_RED 0xAA3333AA
  24. #define COLOR_YELLOW 0xFFFF00AA
  25. #define COLOR_WHITE 0xFFFFFFAA
  26. #define COLOR_BLUE 0x0000BBAA
  27. #define COLOR_LIGHTBLUE 0x33CCFFAA
  28. #define COLOR_ORANGE 0xFF9900AA
  29. #define COLOR_RED 0xAA3333AA
  30. #define COLOR_MAGENTA 0xFF00FFFF
  31. #define COLOR_BLACK 0x000000AA
  32. #define COLOR_BROWN 0XA52A2AAA
  33. #define COLOR_GOLD 0xB8860BAA
  34. #define COLOR_GREENYELLOW 0xADFF2FAA
  35. #define COLOR_LIMEGREEN 0x32CD32AA
  36. #define COLOR_MIDNIGHTBLUE 0X191970AA
  37. #define COLOR_PINK 0xFFC0CBAA
  38.  
  39. new Drones[MAX_PLAYERS];
  40.  
  41. public OnPlayerConnect(playerid)
  42. {
  43.     SetPVarInt( playerid, "DroneSpawned", 0 );
  44.  
  45.     SetPVarFloat( playerid, "OldPosX", 0 );
  46.     SetPVarFloat( playerid, "OldPosY", 0 );
  47.     SetPVarFloat( playerid, "OldPosZ", 0 );
  48.     return 1;
  49. }
  50.  
  51. public OnPlayerDisconnect(playerid, reason)
  52. {
  53.     DestroyVehicle( Drones[playerid] );
  54.     return 1;
  55. }
  56.  
  57. public OnPlayerDeath(playerid, killerid, reason)
  58. {
  59.     if( GetPVarInt( playerid, "DroneSpawned" ) == 1 ) {
  60.         SetPVarInt( playerid, "DroneSpawned", 0 );
  61.         DestroyVehicle( Drones[playerid] );
  62.         SendClientMessage( playerid, COLOR_GREENYELLOW, "Your drone was automatically shut down as you have died." );
  63.     }
  64.     return 1;
  65. }
  66.  
  67. CMD:drone(playerid, params[])
  68. {
  69.     new str[128];
  70.     if( sscanf( params, "s", str ) ) return SendClientMessage( playerid, COLOR_RED, "USAGE: /drone [spawn/detonate/remove]" );
  71.  
  72.     if( strcmp( str, "spawn" ) == 0 ) {
  73.         if( GetPVarInt( playerid, "DroneSpawned" ) == 0 ) {
  74.             new Float:Health;
  75.             GetPlayerHealth( playerid, Health );
  76.  
  77.             if(Health != 0) {
  78.                 new Float:PosX, Float:PosY, Float:PosZ;
  79.                 GetPlayerPos( playerid, PosX, PosY, PosZ );
  80.                 SetPVarFloat( playerid, "OldPosX", PosX );
  81.                 SetPVarFloat( playerid, "OldPosY", PosY );
  82.                 SetPVarFloat( playerid, "OldPosZ", PosZ );
  83.                 SetPVarInt( playerid, "DroneSpawned", 1 );
  84.                 SendClientMessage( playerid, COLOR_GREEN, "You have successfully spawned a drone." );
  85.                 Drones[playerid] = CreateVehicle( 465, PosX, PosY, PosZ + 20, 0, 0, 0, 0, -1 );
  86.                 PutPlayerInVehicle( playerid, Drones[playerid], 0 );
  87.             }
  88.         } else {
  89.             SendClientMessage( playerid, COLOR_RED, "You already have a drone spawned in!" );
  90.         }
  91.     } else {
  92.         if( strcmp( str, "detonate" ) == 0 ) {
  93.             if( GetPVarInt( playerid, "DroneSpawned" ) == 1 ) {
  94.                 new Float:PosX, Float:PosY, Float:PosZ;
  95.                 GetVehiclePos( Drones[playerid], PosX, PosY, PosZ );
  96.  
  97.                 SetPVarInt( playerid, "DroneSpawned", 0 );
  98.                 SendClientMessage( playerid, COLOR_GREEN, "Drone successfully detonated." );
  99.                 DestroyVehicle( Drones[playerid] );
  100.  
  101.                 CreateExplosion( PosX, PosY, PosZ, 7, 25 );
  102.  
  103.                 SetPlayerPos(playerid, GetPVarFloat( playerid, "OldPosX" ), GetPVarFloat( playerid, "OldPosY" ), GetPVarFloat( playerid, "OldPosZ" ));
  104.             } else {
  105.                 SendClientMessage( playerid, COLOR_RED, "You need to have a drone spawned in!" );
  106.             }
  107.         } else {
  108.             if( strcmp( str, "remove" ) == 0 ) {
  109.                 if( GetPVarInt( playerid, "DroneSpawned" ) == 1 ) {
  110.                     SetPVarInt( playerid, "DroneSpawned", 0 );
  111.                     SendClientMessage( playerid, COLOR_GREEN, "You have shut your drone down." );
  112.                     DestroyVehicle( Drones[playerid] );
  113.  
  114.                     SetPlayerPos(playerid, GetPVarFloat( playerid, "OldPosX" ), GetPVarFloat( playerid, "OldPosY" ), GetPVarFloat( playerid, "OldPosZ" ));
  115.                 } else {
  116.                     SendClientMessage( playerid, COLOR_RED, "You need to have a drone spawned in!" );
  117.                 }
  118.             }
  119.         }
  120.     }
  121.     return 1;
  122. }
  123.  
  124. public OnPlayerExitVehicle(playerid, vehicleid)
  125. {
  126.     if( vehicleid == Drones[playerid] ) {
  127.         SendClientMessage( playerid, COLOR_RED, "You can't exit the drone! Use /drone remove or /drone detonate." );
  128.     }
  129.     return 1;
  130. }
Add Comment
Please, Sign In to add comment