Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CMD:takegun(playerid, params[])
- {
- if(!pLoggedIn[playerid])return true;
- new string[128], hid = IsPlayerInProperty(playerid), slotid;
- if(IsPlayerInRangeOfPoint(playerid, 3.0, PropertyData[hid][propertyCheckPos][0], PropertyData[hid][propertyCheckPos][1], PropertyData[hid][propertyCheckPos][2]))
- {
- if(sscanf(params, "d", slotid))return SendClientMessage(playerid, COLOR_ADM, "USAGE:{FFFFFF} /takegun slot_id");
- if(!PropertyData[hid][propertyWeapons][slotid])return SendClientMessage(playerid, COLOR_ADM, "ERROR:{FFFFFF} There's nothing in that slot.");
- if(slotid < 0 || slotid > 20)return SendClientMessage(playerid, COLOR_ADM, "ERROR:{FFFFFF} That slot doesn't exist.");
- GivePlayerGun(playerid, PropertyData[hid][propertyWeapons][slotid], PropertyData[hid][propertyAmmo][slotid], WEAPON_UNKNOWN_GIVEN);
- format(string, sizeof(string), "* %s takes a %s from the house.", ReturnName(playerid, 0), ReturnWeaponName(PropertyData[hid][propertyWeapons][slotid]));
- SetPlayerChatBubble(playerid, string, COLOR_EMOTE, 25.0, 3000);
- SendClientMessage(playerid, COLOR_EMOTE, string);
- 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]),
- PropertyData[hid][propertyAmmo][slotid], hid);
- PropertyData[hid][propertyWeapons][slotid] = 0;
- PropertyData[hid][propertyAmmo][slotid] = 0;
- SaveProperty(hid);
- return true;
- }
- if(IsPlayerInAnyVehicle(playerid))
- {
- vehicleid = GetPlayerVehicleID(playerid);
- }
- else if(!IsPlayerInAnyVehicle(playerid) && GetNearestVehicle(playerid) != INVALID_VEHICLE_ID)
- {
- vehicleid = GetNearestVehicle(playerid);
- new Float: vp[3];
- GetVehicleBoot(vehicleid, vp[0], vp[1], vp[2]);
- if(!IsPlayerInRangeOfPoint(playerid, 2.5, vp[0], vp[1], vp[2]))
- return SendClientMessage(playerid, COLOR_YELLOW, "You aren't near the vehicles trunk.");
- }
- new w_slot_id;
- if(!IsValidFactionCar(vehicleid) && !IsValidPlayerCar(vehicleid))
- return SendClientMessage(playerid, COLOR_ADM, "SERVER: This command can only be used for private vehicles. You are in a public static vehicle.");
- if ( IsValidPlayerCar(vehicleid) )
- {
- if(sscanf(params, "d", w_slot_id)) return SendClientMessage(playerid, COLOR_ADM, "USAGE: /takegun slot_id");
- if ( w_slot_id < 1 || w_slot_id > 4 ) return SendClientMessage(playerid, COLOR_ADM, "ERROR: That slot doesn't exist.");
- if ( !CarData[vehicleid][carWeapons][w_slot_id] ) return SendClientMessage(playerid, COLOR_ADM, "ERROR: There's nothing in that slot.");
- GivePlayerGun(playerid, CarData[vehicleid][carWeapons][w_slot_id], CarData[vehicleid][carWeaponsAmmo][w_slot_id], WEAPON_UNKNOWN_GIVEN);
- format(string, sizeof(string), "* %s takes a %s from the %s.", ReturnName(playerid, 0), ReturnWeaponName(CarData[vehicleid][carWeapons][w_slot_id]), ReturnVehicleName(vehicleid));
- SetPlayerChatBubble(playerid, string, COLOR_EMOTE, 25.0, 3000);
- SendClientMessage(playerid, COLOR_EMOTE, string);
- 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]),
- CarData[vehicleid][carWeaponsAmmo][w_slot_id], ReturnVehicleName(vehicleid), CarData[vehicleid][carID]);
- 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);
- LogVehicleAction(vehicleid, string);
- if(IsValidDynamicObject(CarData[vehicleid][carWeaponObject][w_slot_id]))
- DestroyDynamicObject(CarData[vehicleid][carWeaponObject][w_slot_id]);
- CarData[vehicleid][carWeapons][w_slot_id] = 0;
- CarData[vehicleid][carWeaponsAmmo][w_slot_id] = 0;
- SaveCar(vehicleid);
- return true;
- }
- else if( IsValidFactionCar(vehicleid) )
- {
- if(FactionCar[vehicleid][carFaction] != PlayerData[playerid][pFaction])
- return SendClientMessage(playerid, COLOR_ADM, "ACCESS DENIED:{FFFFFF} You don't have the keys to this vehicle.");
- if(FactionCar[vehicleid][carGunRack])
- {
- if(sscanf(params, "d", w_slot_id)) return SendClientMessage(playerid, COLOR_WHITE, "/takegun slot_id (ID List in /check.)");
- if ( w_slot_id < 0 || w_slot_id > 7 ) return SendClientMessage(playerid, COLOR_ADM, "ERROR:{FFFFFF} That slot ID does not exist.");
- switch ( w_slot_id )
- {
- case 1: {
- GivePlayerGun(playerid, 25, 100, WEAPON_SERVER_GIVEN);
- format(string, sizeof(string), "* %s takes a Shotgun from the %s.", ReturnName(playerid, 0), ReturnVehicleName(vehicleid));
- SetPlayerChatBubble(playerid, string, COLOR_EMOTE, 25.0, 3000);
- SendClientMessage(playerid, COLOR_EMOTE, string);
- }
- case 2: {
- GivePlayerGun(playerid, 29, 200, WEAPON_SERVER_GIVEN);
- format(string, sizeof(string), "* %s takes a MP5 from the %s.", ReturnName(playerid, 0), ReturnVehicleName(vehicleid));
- SetPlayerChatBubble(playerid, string, COLOR_EMOTE, 25.0, 3000);
- SendClientMessage(playerid, COLOR_EMOTE, string);
- }
- case 3: {
- GivePlayerGun(playerid, 31, 200, WEAPON_SERVER_GIVEN);
- format(string, sizeof(string), "* %s takes a M4 from the %s.", ReturnName(playerid, 0), ReturnVehicleName(vehicleid));
- SetPlayerChatBubble(playerid, string, COLOR_EMOTE, 25.0, 3000);
- SendClientMessage(playerid, COLOR_EMOTE, string);
- }
- case 4: { return SendClientMessage(playerid, COLOR_ADM, "SERVER: This is not available right now. "); }
- case 5: {
- GivePlayerGun(playerid, 34, 200, WEAPON_SERVER_GIVEN);
- format(string, sizeof(string), "* %s takes a Sniper Rifle from the %s.", ReturnName(playerid, 0), ReturnVehicleName(vehicleid));
- SetPlayerChatBubble(playerid, string, COLOR_EMOTE, 25.0, 3000);
- SendClientMessage(playerid, COLOR_EMOTE, string);
- }
- case 6: {
- GivePlayerGun(playerid, 43, 100, WEAPON_SERVER_GIVEN);
- format(string, sizeof(string), "* %s takes a Camera from the %s.", ReturnName(playerid, 0), ReturnVehicleName(vehicleid));
- SetPlayerChatBubble(playerid, string, COLOR_EMOTE, 25.0, 3000);
- SendClientMessage(playerid, COLOR_EMOTE, string);
- }
- case 7: {
- GivePlayerGun(playerid, 41, 200, WEAPON_SERVER_GIVEN);
- format(string, sizeof(string), "* %s takes a Spray Can from the %s.", ReturnName(playerid, 0), ReturnVehicleName(vehicleid));
- SetPlayerChatBubble(playerid, string, COLOR_EMOTE, 25.0, 3000);
- SendClientMessage(playerid, COLOR_EMOTE, string);
- }
- }
- return true;
- }
- else
- {
- SendClientMessage(playerid, COLOR_ADM, "SERVER: Unavailable Feature.");
- return true;
- }
- }
- SendClientMessage(playerid, COLOR_ADM, "SERVER: You can't do this right now.");
- return true;
- }
Add Comment
Please, Sign In to add comment