Oblivion_UFF

asd

Feb 8th, 2020
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.03 KB | None | 0 0
  1. CMD:takegun(playerid, params[])
  2. {
  3. if(!pLoggedIn[playerid])return true;
  4.  
  5. new string[128], hid = IsPlayerInProperty(playerid), slotid;
  6.  
  7. if(IsPlayerInRangeOfPoint(playerid, 3.0, PropertyData[hid][propertyCheckPos][0], PropertyData[hid][propertyCheckPos][1], PropertyData[hid][propertyCheckPos][2]))
  8. {
  9. if(sscanf(params, "d", slotid))return SendClientMessage(playerid, COLOR_ADM, "USAGE:{FFFFFF} /takegun slot_id");
  10. if(!PropertyData[hid][propertyWeapons][slotid])return SendClientMessage(playerid, COLOR_ADM, "ERROR:{FFFFFF} There's nothing in that slot.");
  11. if(slotid < 0 || slotid > 20)return SendClientMessage(playerid, COLOR_ADM, "ERROR:{FFFFFF} That slot doesn't exist.");
  12.  
  13. GivePlayerGun(playerid, PropertyData[hid][propertyWeapons][slotid], PropertyData[hid][propertyAmmo][slotid], WEAPON_UNKNOWN_GIVEN);
  14.  
  15. format(string, sizeof(string), "* %s takes a %s from the house.", ReturnName(playerid, 0), ReturnWeaponName(PropertyData[hid][propertyWeapons][slotid]));
  16. SetPlayerChatBubble(playerid, string, COLOR_EMOTE, 25.0, 3000);
  17. SendClientMessage(playerid, COLOR_EMOTE, string);
  18.  
  19. WriteLog("weapon_logs/property_take.txt", "[%s] %s took %s (Ammo: %d) from Property DBID %d", ReturnDate(), ReturnName(playerid, 1), ReturnWeaponName(PropertyData[hid][propertyWeapons][slotid]),
  20. PropertyData[hid][propertyAmmo][slotid], hid);
  21.  
  22. PropertyData[hid][propertyWeapons][slotid] = 0;
  23. PropertyData[hid][propertyAmmo][slotid] = 0;
  24.  
  25. SaveProperty(hid);
  26. return true;
  27. }
  28. if(IsPlayerInAnyVehicle(playerid))
  29. {
  30. vehicleid = GetPlayerVehicleID(playerid);
  31. }
  32. else if(!IsPlayerInAnyVehicle(playerid) && GetNearestVehicle(playerid) != INVALID_VEHICLE_ID)
  33. {
  34. vehicleid = GetNearestVehicle(playerid);
  35. new Float: vp[3];
  36. GetVehicleBoot(vehicleid, vp[0], vp[1], vp[2]);
  37.  
  38. if(!IsPlayerInRangeOfPoint(playerid, 2.5, vp[0], vp[1], vp[2]))
  39. return SendClientMessage(playerid, COLOR_YELLOW, "You aren't near the vehicles trunk.");
  40. }
  41. new w_slot_id;
  42.  
  43. if(!IsValidFactionCar(vehicleid) && !IsValidPlayerCar(vehicleid))
  44. return SendClientMessage(playerid, COLOR_ADM, "SERVER: This command can only be used for private vehicles. You are in a public static vehicle.");
  45.  
  46. if ( IsValidPlayerCar(vehicleid) )
  47. {
  48. if(sscanf(params, "d", w_slot_id)) return SendClientMessage(playerid, COLOR_ADM, "USAGE: /takegun slot_id");
  49. if ( w_slot_id < 1 || w_slot_id > 4 ) return SendClientMessage(playerid, COLOR_ADM, "ERROR: That slot doesn't exist.");
  50. if ( !CarData[vehicleid][carWeapons][w_slot_id] ) return SendClientMessage(playerid, COLOR_ADM, "ERROR: There's nothing in that slot.");
  51.  
  52. GivePlayerGun(playerid, CarData[vehicleid][carWeapons][w_slot_id], CarData[vehicleid][carWeaponsAmmo][w_slot_id], WEAPON_UNKNOWN_GIVEN);
  53.  
  54. format(string, sizeof(string), "* %s takes a %s from the %s.", ReturnName(playerid, 0), ReturnWeaponName(CarData[vehicleid][carWeapons][w_slot_id]), ReturnVehicleName(vehicleid));
  55. SetPlayerChatBubble(playerid, string, COLOR_EMOTE, 25.0, 3000);
  56. SendClientMessage(playerid, COLOR_EMOTE, string);
  57.  
  58. WriteLog("weapon_logs/vehicle_take.txt", "[%s] %s took %s (Ammo: %d) from %s (Vehicle DBID %d)", ReturnDate(), ReturnName(playerid, 1), ReturnWeaponName(CarData[vehicleid][carWeapons][w_slot_id]),
  59. CarData[vehicleid][carWeaponsAmmo][w_slot_id], ReturnVehicleName(vehicleid), CarData[vehicleid][carID]);
  60.  
  61. format(string, sizeof(string), "%s took a %s[%d] (slot %d)", ReturnName(playerid), ReturnWeaponName(CarData[vehicleid][carWeapons][w_slot_id]), CarData[vehicleid][carWeaponsAmmo][w_slot_id], w_slot_id);
  62. LogVehicleAction(vehicleid, string);
  63.  
  64. if(IsValidDynamicObject(CarData[vehicleid][carWeaponObject][w_slot_id]))
  65. DestroyDynamicObject(CarData[vehicleid][carWeaponObject][w_slot_id]);
  66.  
  67. CarData[vehicleid][carWeapons][w_slot_id] = 0;
  68. CarData[vehicleid][carWeaponsAmmo][w_slot_id] = 0;
  69.  
  70. SaveCar(vehicleid);
  71. return true;
  72. }
  73. else if( IsValidFactionCar(vehicleid) )
  74. {
  75. if(FactionCar[vehicleid][carFaction] != PlayerData[playerid][pFaction])
  76. return SendClientMessage(playerid, COLOR_ADM, "ACCESS DENIED:{FFFFFF} You don't have the keys to this vehicle.");
  77.  
  78. if(FactionCar[vehicleid][carGunRack])
  79. {
  80.  
  81. if(sscanf(params, "d", w_slot_id)) return SendClientMessage(playerid, COLOR_WHITE, "/takegun slot_id (ID List in /check.)");
  82. if ( w_slot_id < 0 || w_slot_id > 7 ) return SendClientMessage(playerid, COLOR_ADM, "ERROR:{FFFFFF} That slot ID does not exist.");
  83.  
  84. switch ( w_slot_id )
  85. {
  86. case 1: {
  87. GivePlayerGun(playerid, 25, 100, WEAPON_SERVER_GIVEN);
  88.  
  89. format(string, sizeof(string), "* %s takes a Shotgun from the %s.", ReturnName(playerid, 0), ReturnVehicleName(vehicleid));
  90. SetPlayerChatBubble(playerid, string, COLOR_EMOTE, 25.0, 3000);
  91. SendClientMessage(playerid, COLOR_EMOTE, string);
  92. }
  93. case 2: {
  94. GivePlayerGun(playerid, 29, 200, WEAPON_SERVER_GIVEN);
  95.  
  96. format(string, sizeof(string), "* %s takes a MP5 from the %s.", ReturnName(playerid, 0), ReturnVehicleName(vehicleid));
  97. SetPlayerChatBubble(playerid, string, COLOR_EMOTE, 25.0, 3000);
  98. SendClientMessage(playerid, COLOR_EMOTE, string);
  99. }
  100. case 3: {
  101. GivePlayerGun(playerid, 31, 200, WEAPON_SERVER_GIVEN);
  102.  
  103. format(string, sizeof(string), "* %s takes a M4 from the %s.", ReturnName(playerid, 0), ReturnVehicleName(vehicleid));
  104. SetPlayerChatBubble(playerid, string, COLOR_EMOTE, 25.0, 3000);
  105. SendClientMessage(playerid, COLOR_EMOTE, string);
  106. }
  107. case 4: { return SendClientMessage(playerid, COLOR_ADM, "SERVER: This is not available right now. "); }
  108. case 5: {
  109. GivePlayerGun(playerid, 34, 200, WEAPON_SERVER_GIVEN);
  110.  
  111. format(string, sizeof(string), "* %s takes a Sniper Rifle from the %s.", ReturnName(playerid, 0), ReturnVehicleName(vehicleid));
  112. SetPlayerChatBubble(playerid, string, COLOR_EMOTE, 25.0, 3000);
  113. SendClientMessage(playerid, COLOR_EMOTE, string);
  114. }
  115. case 6: {
  116. GivePlayerGun(playerid, 43, 100, WEAPON_SERVER_GIVEN);
  117.  
  118. format(string, sizeof(string), "* %s takes a Camera from the %s.", ReturnName(playerid, 0), ReturnVehicleName(vehicleid));
  119. SetPlayerChatBubble(playerid, string, COLOR_EMOTE, 25.0, 3000);
  120. SendClientMessage(playerid, COLOR_EMOTE, string);
  121. }
  122. case 7: {
  123. GivePlayerGun(playerid, 41, 200, WEAPON_SERVER_GIVEN);
  124.  
  125. format(string, sizeof(string), "* %s takes a Spray Can from the %s.", ReturnName(playerid, 0), ReturnVehicleName(vehicleid));
  126. SetPlayerChatBubble(playerid, string, COLOR_EMOTE, 25.0, 3000);
  127. SendClientMessage(playerid, COLOR_EMOTE, string);
  128. }
  129. }
  130. return true;
  131. }
  132. else
  133. {
  134. SendClientMessage(playerid, COLOR_ADM, "SERVER: Unavailable Feature.");
  135. return true;
  136. }
  137. }
  138. SendClientMessage(playerid, COLOR_ADM, "SERVER: You can't do this right now.");
  139. return true;
  140. }
Add Comment
Please, Sign In to add comment