Advertisement
EvanAbagail

Drivable Pumpkin v2.0

Nov 19th, 2014
366
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 5.00 KB | None | 0 0
  1. #include a_samp
  2. #include zcmd
  3. new bool: DrivingPumpkin[MAX_PLAYERS];
  4. new Pumpkin[MAX_PLAYERS] = INVALID_OBJECT_ID;
  5. new bool: AdminOnly = false;
  6. #define PUMPKIN_SPEED 5.0
  7. CMD:togadminonly(playerid, params[])
  8. {
  9.     if(IsPlayerAdmin(playerid))
  10.     {
  11.         if(AdminOnly == true)
  12.         {
  13.             AdminOnly = false;
  14.             SendClientMessage(playerid, -1, "You have unrestricted the pumpkin system.");
  15.             return true;
  16.         }
  17.         else
  18.         {
  19.             AdminOnly = true;
  20.             SendClientMessage(playerid, -1, "You have restricted the pumpkin system to administrators.");
  21.             return true;
  22.         }
  23.     }
  24.     return true;
  25. }
  26. CMD:createpumpkin(playerid, params[])
  27. {
  28.         if(!IsPlayerAdmin(playerid) && AdminOnly == true)
  29.         {
  30.             SendClientMessage(playerid, -1, "This command has been restricted to administrators.");
  31.             return true;
  32.         }
  33.         if(DrivingPumpkin[playerid])
  34.         {
  35.             return SendClientMessage(playerid, -1, "You're already driving a pumpkin. Use /destroypumpkin to stop driving.");
  36.         }
  37.         ApplyAnimation(playerid, "FOOD", "FF_Sit_Eat2", 4.0, 1, 0, 0, 1, 0, 1);
  38.         new Float: X, Float: Y, Float: Z;
  39.         GetPlayerPos(playerid, X, Y, Z);
  40.         Pumpkin[playerid] = CreateObject(19320, X, Y, Z, 0.0, 0.0, 0.0);
  41.         DrivingPumpkin[playerid] = true;
  42.         TogglePlayerControllable(playerid, false); // - Manually controlled movements.
  43.         return 1;
  44. }
  45.  
  46. CMD:destroypumpkin(playerid, params[])
  47. {
  48.         if(DrivingPumpkin[playerid] == true)
  49.         {
  50.                 DestroyObject(Pumpkin[playerid]);
  51.                 DrivingPumpkin[playerid] = false;
  52.                 Pumpkin[playerid] = INVALID_OBJECT_ID;
  53.                 TogglePlayerControllable(playerid, true);
  54.                 SetCameraBehindPlayer(playerid);
  55.                 return true;
  56.         }
  57. }
  58.  
  59. CMD:pumpkin(playerid, params[])
  60. {
  61.         if(isnull(params)) return true;
  62.         if(DrivingPumpkin[playerid] == false) return SendClientMessage(playerid, -1, "You're not driving a pumpkin.");
  63.         if(strcmp(params, "up", true) == 0)
  64.         {
  65.             new Float: pos[3];
  66.             GetObjectPos(Pumpkin[playerid], pos[0], pos[1], pos[2]);
  67.                 SetObjectPos(Pumpkin[playerid], pos[0], pos[1], pos[2]+1.0);
  68.         }
  69.         if(strcmp(params, "down", true) == 0)
  70.         {
  71.             new Float: pos[3];
  72.             GetObjectPos(Pumpkin[playerid], pos[0], pos[1], pos[2]);
  73.                 SetObjectPos(Pumpkin[playerid], pos[0], pos[1], pos[2]-1.0);
  74.         }
  75.         return 1;
  76. }
  77.  
  78. public OnFilterScriptExit()
  79. {
  80.         for (new i = 0; i != MAX_PLAYERS; ++i)
  81.         {
  82.                  if (IsPlayerConnected(i))
  83.              {
  84.                 if(DrivingPumpkin[i] == true)
  85.                 {
  86.                         DrivingPumpkin[i] = false;
  87.                         DestroyObject(Pumpkin[i]);
  88.                         Pumpkin[i] = -1;
  89.                         }
  90.                 }
  91.         }
  92. }
  93.  
  94. public OnPlayerDisconnect(playerid)
  95. {
  96.         if(DrivingPumpkin[playerid] == true)
  97.         {
  98.             DrivingPumpkin[playerid] = false;
  99.                 DestroyObject(Pumpkin[playerid]);
  100.                 Pumpkin[playerid] = -1;
  101.         }
  102.         return true;
  103. }
  104. public OnPlayerUpdate(playerid)
  105. {
  106.         if(DrivingPumpkin[playerid] == true)
  107.         {
  108.         new Keys,ud,lr;
  109.         GetPlayerKeys(playerid,Keys,ud,lr);
  110.         new objectid = Pumpkin[playerid];
  111.  
  112.                 new Float: pos[3];
  113.                 GetObjectPos(objectid, pos[0], pos[1], pos[2]);
  114.                 SetPlayerPos(playerid, pos[0], pos[1], pos[2]+0.5);
  115.             if(ud == KEY_UP)
  116.             {
  117.                 new Float: X, Float: Y, Float: Z;
  118.                 GetObjectPos(objectid, X, Y, Z);
  119.                         MoveObject(objectid, X, Y+2.0, Z, PUMPKIN_SPEED, 0.0, 0.0, 0.0);
  120.                         return true;
  121.                 }
  122.  
  123.             else if(ud == KEY_DOWN)
  124.             {
  125.                 new Float: X, Float: Y, Float: Z;
  126.                 GetObjectPos(objectid, X, Y, Z);
  127.                         MoveObject(objectid, X, Y-2.0, Z, PUMPKIN_SPEED, 0.0, 0.0, 0.0);
  128.                         return true;
  129.                 }
  130.  
  131.             if(lr == KEY_LEFT)
  132.             {
  133.                 new Float: X, Float: Y, Float: Z;
  134.                 GetObjectPos(objectid, X, Y, Z);
  135.                         MoveObject(objectid, X-2.0, Y, Z, PUMPKIN_SPEED, 0.0, 0.0, 0.0);
  136.                         return true;
  137.                 }
  138.             else if(lr == KEY_RIGHT)
  139.             {
  140.             new Float: X, Float: Y, Float: Z;
  141.                 GetObjectPos(objectid, X, Y, Z);
  142.                         MoveObject(objectid, X+2.0, Y, Z, PUMPKIN_SPEED, 0.0, 0.0, 0.0);
  143.                         return true;
  144.                 }
  145.         }
  146.     return 1;
  147. }
  148.  
  149. public OnPlayerDeath(playerid, killerid, reason)
  150. {
  151.         if(DrivingPumpkin[playerid] == true)
  152.         {
  153.                 DestroyObject(Pumpkin[playerid]);
  154.                 Pumpkin[playerid] = -1;
  155.                 DrivingPumpkin[playerid] = false;
  156.                 return 1;
  157.         }
  158.         return true;
  159. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement