Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #if defined _weaponsac_included
- #endinput
- #endif
- #define _weaponsac_included
- #include <YSI\y_hooks>
- #define MAX_PLAYER_CLASSES (300)
- #define MAX_WEAPON_AMMO (32767)
- forward OnPlayerPurchaseWeapon(playerid, weaponid, totalammo);
- enum E_CLASS_DATA
- {
- E_CLASS_WEAPON1,
- E_CLASS_WEAPON2,
- E_CLASS_WEAPON3,
- E_CLASS_AMMO1,
- E_CLASS_AMMO2,
- E_CLASS_AMMO3
- };
- enum E_SPAWNI_DATA
- {
- E_SPAWNI_WEAPON1,
- E_SPAWNI_WEAPON2,
- E_SPAWNI_WEAPON3,
- E_SPAWNI_AMMO1,
- E_SPAWNI_AMMO2,
- E_SPAWNI_AMMO3
- };
- new
- PlayerClassData [MAX_PLAYER_CLASSES] [E_CLASS_DATA],
- PlayerSpawnInfo [MAX_PLAYERS] [E_SPAWNI_DATA],
- PlayerWeapons [MAX_PLAYERS] [12],
- PlayerWepAmmo [MAX_PLAYERS] [12],
- PlayerClassID [MAX_PLAYERS],
- PickupModelID [MAX_PICKUPS],
- PickupType [MAX_PICKUPS char],
- bool: FallingWithParachute [MAX_PLAYERS],
- LastPlayerWeapon [MAX_PLAYERS],
- LastPlayerAmmo [MAX_PLAYERS];
- new
- interiorsturnedoff = 0;
- public OnPlayerConnect(playerid)
- {
- for(new slot = 0; slot < 12; slot++)
- {
- PlayerWeapons[playerid][slot] = 0;
- PlayerWepAmmo[playerid][slot] = 0;
- }
- PlayerClassID [playerid] = -1;
- LastPlayerWeapon [playerid] = 0;
- LastPlayerAmmo [playerid] = 0;
- for(new i; E_SPAWNI_DATA:i < E_SPAWNI_DATA; i++)
- {
- PlayerSpawnInfo[playerid][E_SPAWNI_DATA:i] = 0;
- }
- FallingWithParachute[playerid] = false;
- #if defined weapons_OnPlayerConnect
- return weapons_OnPlayerConnect(playerid);
- #else
- return 1;
- #endif
- }
- #if defined _ALS_OnPlayerConnect
- #undef OnPlayerConnect
- #else
- #define _ALS_OnPlayerConnect
- #endif
- #define OnPlayerConnect weapons_OnPlayerConnect
- #if defined weapons_OnPlayerConnect
- forward weapons_OnPlayerConnect(playerid);
- #endif
- public OnPlayerRequestClass(playerid, classid)
- {
- PlayerClassID[playerid] = classid;
- #if defined weapons_OnPlayerRequestClass
- return weapons_OnPlayerRequestClass(playerid, classid);
- #else
- return 1;
- #endif
- }
- #if defined _ALS_OnPlayerRequestClass
- #undef OnPlayerRequestClass
- #else
- #define _ALS_OnPlayerRequestClass
- #endif
- #define OnPlayerRequestClass weapons_OnPlayerRequestClass
- #if defined weapons_OnPlayerRequestClass
- forward weapons_OnPlayerRequestClass(playerid, classid);
- #endif
- public OnPlayerSpawn(playerid)
- {
- SetClassWeapons(playerid);
- #if defined weapons_OnPlayerSpawn
- return weapons_OnPlayerSpawn(playerid);
- #else
- return 1;
- #endif
- }
- #if defined _ALS_OnPlayerSpawn
- #undef OnPlayerSpawn
- #else
- #define _ALS_OnPlayerSpawn
- #endif
- #define OnPlayerSpawn weapons_OnPlayerSpawn
- #if defined weapons_OnPlayerSpawn
- forward weapons_OnPlayerSpawn(playerid);
- #endif
- public OnPlayerDeath(playerid, killerid, reason)
- {
- weapons_ResetPlayerWeapons(playerid);
- FallingWithParachute [playerid] = false;
- LastPlayerWeapon [playerid] = 0;
- LastPlayerAmmo [playerid] = 0;
- #if defined weapons_OnPlayerDeath
- return weapons_OnPlayerDeath(playerid, killerid, reason);
- #else
- return 1;
- #endif
- }
- #if defined _ALS_OnPlayerDeath
- #undef OnPlayerDeath
- #else
- #define _ALS_OnPlayerDeath
- #endif
- #define OnPlayerDeath weapons_OnPlayerDeath
- #if defined weapons_OnPlayerDeath
- forward weapons_OnPlayerDeath(playerid, killerid, reason);
- #endif
- public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
- {
- if(46 >= weaponid > 0)
- {
- static ammo, slot;
- ammo = GetPlayerAmmo(playerid),
- slot = GetWeaponSlotID(weaponid);
- if(ammo < 1 && PlayerWeapons[playerid][slot] == weaponid)
- {
- PlayerWeapons[playerid][slot] = 0;
- PlayerWepAmmo[playerid][slot] = 0;
- return 1;
- }
- if(IsValidPlayerWeapon(playerid, slot) != weaponid)
- {
- SetPlayerLegitWeapons(playerid);
- SetPlayerArmedWeapon(playerid, 0);
- return 0;
- }
- }
- #if defined weapons_OnPlayerWeaponShot
- return weapons_OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, fX, fY, fZ);
- #else
- return 1;
- #endif
- }
- #if defined _ALS_OnPlayerWeaponShot
- #undef OnPlayerWeaponShot
- #else
- #define _ALS_OnPlayerWeaponShot
- #endif
- #define OnPlayerWeaponShot weapons_OnPlayerWeaponShot
- #if defined weapons_OnPlayerWeaponShot
- forward weapons_OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ);
- #endif
- public OnPlayerUpdate(playerid)
- {
- if(!(GetPlayerWeaponState(playerid) == -1 && !IsPlayerInAnyVehicle(playerid)))
- {
- static
- weaponid,
- ammo,
- slot;
- weaponid = GetPlayerWeapon(playerid);
- if(46 >= weaponid > 0 && weaponid != WEAPON_BOMB)
- {
- ammo = GetPlayerAmmo(playerid),
- slot = GetWeaponSlotID(weaponid);
- if(PlayerWepAmmo[playerid][slot] < 1 && PlayerWeapons[playerid][slot] == weaponid)
- {
- PlayerWeapons[playerid][slot] = 0;
- PlayerWepAmmo[playerid][slot] = 0;
- return 1;
- }
- else if(!IsPlayerUsingParachute(playerid) && FallingWithParachute[playerid])
- {
- if(PlayerWeapons[playerid][11] == WEAPON_PARACHUTE)
- {
- FallingWithParachute[playerid] = false;
- PlayerWeapons[playerid][slot] = 0;
- PlayerWepAmmo[playerid][slot] = 0;
- return 1;
- }
- }
- if(IsValidPlayerWeapon(playerid, slot) != weaponid)
- {
- if(IsPlayerBuyingInAmmunation(playerid))
- {
- if(funcidx("OnPlayerPurchaseWeapon") != -1)
- {
- if(!CallLocalFunction("OnPlayerPurchaseWeapon", "iii", playerid, weaponid, ammo))
- {
- SetPlayerLegitWeapons(playerid);
- return 0;
- }
- }
- PlayerWeapons[playerid][slot] = weaponid;
- PlayerWepAmmo[playerid][slot] = ammo;
- LastPlayerAmmo[playerid] = ammo;
- SetPlayerArmedWeapon(playerid, weaponid);
- }
- else
- {
- if(GetPlayerAnimationIndex(playerid) == 645 || GetPlayerAnimationIndex(playerid) == 646)
- {
- if(GetWeaponSlotID(LastPlayerWeapon[playerid]) == 8 && LastPlayerAmmo[playerid] == 2)
- {
- return 1;
- }
- }
- else if(GetPlayerWeaponState(playerid) == WEAPONSTATE_NO_BULLETS)
- {
- return 1;
- }
- else
- {
- SetPlayerLegitWeapons(playerid);
- SetPlayerArmedWeapon(playerid, 0);
- return 0;
- }
- }
- }
- static keys, ud, lr;
- GetPlayerKeys(playerid, keys, ud, lr);
- if(ammo > PlayerWepAmmo[playerid][slot] || MAX_WEAPON_AMMO < ammo < 1)
- {
- if(IsPlayerBuyingInAmmunation(playerid))
- {
- if(funcidx("OnPlayerPurchaseWeapon") != -1)
- {
- if(!CallLocalFunction("OnPlayerPurchaseWeapon", "iii", playerid, weaponid, ammo))
- {
- SetPlayerLegitWeapons(playerid);
- return 0;
- }
- }
- PlayerWepAmmo[playerid][slot] = ammo;
- LastPlayerAmmo[playerid] = ammo;
- }
- else
- {
- SetPlayerLegitWeapons(playerid);
- SetPlayerArmedWeapon(playerid, weaponid);
- return 0;
- }
- }
- else
- {
- PlayerWepAmmo[playerid][slot] = ammo;
- switch(slot)
- {
- case 2..9:
- {
- if(IsPlayerUsingWeapon(playerid) || GetPlayerAnimationIndex(playerid) == 644)
- {
- if((keys & KEY_FIRE))
- {
- if(LastPlayerWeapon[playerid] != weaponid)
- {
- LastPlayerAmmo[playerid] = ammo;
- }
- if(slot == 8 && ammo == 1)
- {
- if(GetPlayerAnimationIndex(playerid) == 644)
- {
- PlayerWepAmmo[playerid][slot] --;
- }
- }
- else if(slot == 9 && ammo == 1)
- {
- PlayerWepAmmo[playerid][slot] --;
- }
- else if(LastPlayerAmmo[playerid] < ammo)
- {
- PlayerWepAmmo[playerid][slot] --;
- LastPlayerAmmo[playerid] = ammo;
- }
- }
- }
- }
- case 11:
- {
- if(GetPlayerAnimationIndex(playerid) == 638)
- {
- if(!IsPlayerInAnyVehicle(playerid))
- return 0;
- }
- else if(IsPlayerUsingParachute(playerid) && !FallingWithParachute[playerid])
- {
- FallingWithParachute[playerid] = true;
- }
- }
- }
- }
- }
- }
- #if defined weapons_OnPlayerUpdate
- return weapons_OnPlayerUpdate(playerid);
- #else
- return 1;
- #endif
- }
- #if defined _ALS_OnPlayerUpdate
- #undef OnPlayerUpdate
- #else
- #define _ALS_OnPlayerUpdate
- #endif
- #define OnPlayerUpdate weapons_OnPlayerUpdate
- #if defined weapons_OnPlayerUpdate
- forward weapons_OnPlayerUpdate(playerid);
- #endif
- public OnPlayerPickUpPickup(playerid, pickupid)
- {
- if(pickupid != -1)
- {
- static weaponid;
- weaponid = GetWeaponIDFromModel(PickupModelID[pickupid]);
- if(weaponid)
- {
- static slot;
- slot = GetWeaponSlotID(weaponid);
- if(PickupType{pickupid} == 2 || PickupType{pickupid} == 3 || PickupType{pickupid} == 15 || PickupType{pickupid} == 22)
- {
- PlayerWeapons[playerid][slot] = weaponid;
- PlayerWepAmmo[playerid][slot] += GetWeaponPickupAmmoDifference(weaponid);
- SetPlayerArmedWeapon(playerid, weaponid);
- }
- }
- }
- #if defined weapons_OnPlayerPickUpPickup
- return weapons_OnPlayerPickUpPickup(playerid, pickupid);
- #else
- return 1;
- #endif
- }
- #if defined _ALS_OnPlayerPickUpPickup
- #undef OnPlayerPickUpPickup
- #else
- #define _ALS_OnPlayerPickUpPickup
- #endif
- #define OnPlayerPickUpPickup weapons_OnPlayerPickUpPickup
- #if defined weapons_OnPlayerPickUpPickup
- forward weapons_OnPlayerPickUpPickup(playerid, pickupid);
- #endif
- stock acwep_DisableInteriorEnterExits()
- {
- interiorsturnedoff = 1;
- return DisableInteriorEnterExits();
- }
- stock weapons_AddPlayerClass(skin, Float:x, Float:y, Float:z, Float:Angle, weapon1, weapon1_ammo, weapon2, weapon2_ammo, weapon3, weapon3_ammo)
- {
- static classid;
- classid = AddPlayerClass(skin, x, y, z, Angle, weapon1, weapon1_ammo, weapon2, weapon2_ammo, weapon3, weapon3_ammo);
- if(weapon1 > 0 && weapon1_ammo > 0)
- {
- PlayerClassData[classid][E_CLASS_WEAPON1] = weapon1;
- PlayerClassData[classid][E_CLASS_AMMO1] = weapon1_ammo;
- }
- if(weapon2 > 0 && weapon2_ammo > 0)
- {
- PlayerClassData[classid][E_CLASS_WEAPON2] = weapon2;
- PlayerClassData[classid][E_CLASS_AMMO2] = weapon2_ammo;
- }
- if(weapon3 > 0 && weapon3_ammo > 0)
- {
- PlayerClassData[classid][E_CLASS_WEAPON3] = weapon3;
- PlayerClassData[classid][E_CLASS_AMMO3] = weapon3_ammo;
- }
- }
- stock weapons_AddPlayerClassEx(teamid, skin, Float:x, Float:y, Float:z, Float:Angle, weapon1, weapon1_ammo, weapon2, weapon2_ammo, weapon3, weapon3_ammo)
- {
- static classid;
- classid = AddPlayerClassEx(teamid, skin, x, y, z, Angle, weapon, weapon1_ammo, weapon2, weapon2_ammo, weapon3, weapon3_ammo);
- if(weapon1 > 0 && weapon1_ammo > 0)
- {
- PlayerClassData[classid][E_CLASS_WEAPON1] = weapon1;
- PlayerClassData[classid][E_CLASS_AMMO1] = weapon1_ammo;
- }
- if(weapon2 > 0 && weapon2_ammo > 0)
- {
- PlayerClassData[classid][E_CLASS_WEAPON2] = weapon2;
- PlayerClassData[classid][E_CLASS_AMMO2] = weapon2_ammo;
- }
- if(weapon3 > 0 && weapon3_ammo > 0)
- {
- PlayerClassData[classid][E_CLASS_WEAPON3] = weapon3;
- PlayerClassData[classid][E_CLASS_AMMO3] = weapon3_ammo;
- }
- }
- stock weapons_SetSpawnInfo(playerid, team, skin, Float:x, Float:y, Float:z, rotation, weapon1, weapon1_ammo, weapon2, weapon2_ammo, weapon3, weapon3_ammo)
- {
- if(weapon1 > 0 && weapon1_ammo > 0)
- {
- PlayerClassData[playerid][E_SPAWNI_WEAPON1] = weapon1;
- PlayerClassData[playerid][E_SPAWNI_AMMO1] = weapon1_ammo;
- }
- if(weapon2 > 0 && weapon2_ammo > 0)
- {
- PlayerClassData[playerid][E_SPAWNI_WEAPON2] = weapon2;
- PlayerClassData[playerid][E_SPAWNI_AMMO2] = weapon2_ammo;
- }
- if(weapon3 > 0 && weapon3_ammo > 0)
- {
- PlayerClassData[playerid][E_SPAWNI_WEAPON3] = weapon3;
- PlayerClassData[playerid][E_SPAWNI_AMMO3] = weapon3_ammo;
- }
- return SetSpawnInfo(playerid, team, skin, x, y, z, rotation, weapon1, weapon1_ammo, weapon2, weapon2_ammo, weapon3, weapon3_ammo);
- }
- stock SetClassWeapons(playerid)
- {
- if(PlayerClassID[playerid] != -1)
- {
- if(PlayerClassData[PlayerClassID[playerid]][E_CLASS_WEAPON1])
- {
- PlayerWeapons[playerid][GetWeaponSlotID(PlayerClassData[PlayerClassID[playerid]][E_CLASS_WEAPON1])] = PlayerClassData[PlayerClassID[playerid]][E_CLASS_WEAPON1];
- PlayerWepAmmo[playerid][GetWeaponSlotID(PlayerClassData[PlayerClassID[playerid]][E_CLASS_WEAPON1])] = PlayerClassData[PlayerClassID[playerid]][E_CLASS_AMMO1];
- }
- if(PlayerClassData[PlayerClassID[playerid]][E_CLASS_WEAPON2])
- {
- PlayerWeapons[playerid][GetWeaponSlotID(PlayerClassData[PlayerClassID[playerid]][E_CLASS_WEAPON2])] = PlayerClassData[PlayerClassID[playerid]][E_CLASS_WEAPON2];
- PlayerWepAmmo[playerid][GetWeaponSlotID(PlayerClassData[PlayerClassID[playerid]][E_CLASS_WEAPON2])] = PlayerClassData[PlayerClassID[playerid]][E_CLASS_AMMO2];
- }
- if(PlayerClassData[PlayerClassID[playerid]][E_CLASS_WEAPON3])
- {
- PlayerWeapons[playerid][GetWeaponSlotID(PlayerClassData[PlayerClassID[playerid]][E_CLASS_WEAPON3])] = PlayerClassData[PlayerClassID[playerid]][E_CLASS_WEAPON3];
- PlayerWepAmmo[playerid][GetWeaponSlotID(PlayerClassData[PlayerClassID[playerid]][E_CLASS_WEAPON3])] = PlayerClassData[PlayerClassID[playerid]][E_CLASS_AMMO3];
- }
- }
- if(PlayerSpawnInfo[playerid][E_SPAWNI_WEAPON1] && PlayerSpawnInfo[playerid][E_SPAWNI_AMMO1])
- {
- PlayerWeapons[playerid][GetWeaponSlotID(PlayerSpawnInfo[playerid][E_SPAWNI_WEAPON1])] = PlayerSpawnInfo[playerid][E_SPAWNI_WEAPON1];
- PlayerWepAmmo[playerid][GetWeaponSlotID(PlayerSpawnInfo[playerid][E_SPAWNI_WEAPON1])] = PlayerSpawnInfo[playerid][E_SPAWNI_AMMO1];
- }
- if(PlayerSpawnInfo[playerid][E_SPAWNI_WEAPON2] && PlayerSpawnInfo[playerid][E_SPAWNI_AMMO2])
- {
- PlayerWeapons[playerid][GetWeaponSlotID(PlayerSpawnInfo[playerid][E_SPAWNI_WEAPON2])] = PlayerSpawnInfo[playerid][E_SPAWNI_WEAPON2];
- PlayerWepAmmo[playerid][GetWeaponSlotID(PlayerSpawnInfo[playerid][E_SPAWNI_WEAPON2])] = PlayerSpawnInfo[playerid][E_SPAWNI_AMMO2];
- }
- if(PlayerSpawnInfo[playerid][E_SPAWNI_WEAPON3] && PlayerSpawnInfo[playerid][E_SPAWNI_AMMO3])
- {
- PlayerWeapons[playerid][GetWeaponSlotID(PlayerSpawnInfo[playerid][E_SPAWNI_WEAPON3])] = PlayerSpawnInfo[playerid][E_SPAWNI_WEAPON3];
- PlayerWepAmmo[playerid][GetWeaponSlotID(PlayerSpawnInfo[playerid][E_SPAWNI_WEAPON3])] = PlayerSpawnInfo[playerid][E_SPAWNI_AMMO3];
- }
- return 1;
- }
- stock weapons_AddStaticPickup(model, type, Float:X, Float:Y, Float:Z, Virtualworld)
- {
- static pickupid;
- pickupid = CreatePickup(model, type, X, Y, Z, Virtualworld);
- if(pickupid != -1)
- {
- PickupModelID [pickupid] = model;
- PickupType {pickupid} = type;
- }
- return pickupid;
- }
- stock weapons_CreatePickup(model, type, Float:X, Float:Y, Float:Z, Virtualworld)
- {
- static pickupid;
- pickupid = CreatePickup(model, type, X, Y, Z, Virtualworld);
- if(pickupid != -1)
- {
- PickupModelID [pickupid] = model;
- PickupType {pickupid} = type;
- }
- return pickupid;
- }
- stock GetWeaponIDFromModel(model)
- {
- switch(model)
- {
- case 331: return WEAPON_BRASSKNUCKLE;
- case 333: return WEAPON_GOLFCLUB;
- case 334: return WEAPON_NITESTICK;
- case 335: return WEAPON_KNIFE;
- case 336: return WEAPON_BAT;
- case 337: return WEAPON_SHOVEL;
- case 338: return WEAPON_POOLSTICK;
- case 339: return WEAPON_KATANA;
- case 341: return WEAPON_CHAINSAW;
- case 321: return WEAPON_DILDO;
- case 322: return WEAPON_DILDO2;
- case 323: return WEAPON_VIBRATOR;
- case 324: return WEAPON_VIBRATOR2;
- case 325: return WEAPON_FLOWER;
- case 326: return WEAPON_CANE;
- case 342: return WEAPON_GRENADE;
- case 343: return WEAPON_TEARGAS;
- case 344: return WEAPON_MOLTOV;
- case 346: return WEAPON_COLT45;
- case 347: return WEAPON_SILENCED;
- case 348: return WEAPON_DEAGLE;
- case 349: return WEAPON_SHOTGUN;
- case 350: return WEAPON_SAWEDOFF;
- case 351: return WEAPON_SHOTGSPA;
- case 352: return WEAPON_UZI;
- case 353: return WEAPON_MP5;
- case 355: return WEAPON_AK47;
- case 356: return WEAPON_M4;
- case 372: return WEAPON_TEC9;
- case 357: return WEAPON_RIFLE;
- case 358: return WEAPON_SNIPER;
- case 359: return WEAPON_ROCKETLAUNCHER;
- case 360: return WEAPON_HEATSEEKER;
- case 361: return WEAPON_FLAMETHROWER;
- case 362: return WEAPON_MINIGUN;
- case 363: return WEAPON_SATCHEL;
- case 364: return WEAPON_BOMB;
- case 365: return WEAPON_SPRAYCAN;
- case 366: return WEAPON_FIREEXTINGUISHER;
- case 367: return WEAPON_CAMERA;
- case 368: return 44;
- case 369: return 45;
- case 371: return WEAPON_PARACHUTE;
- default: return 0;
- }
- return 0;
- }
- stock GetWeaponModel(weaponid)
- {
- switch(weaponid)
- {
- case WEAPON_BRASSKNUCKLE: return 331;
- case WEAPON_GOLFCLUB: return 333;
- case WEAPON_NITESTICK: return 334;
- case WEAPON_KNIFE: return 335;
- case WEAPON_BAT: return 336;
- case WEAPON_SHOVEL: return 337;
- case WEAPON_POOLSTICK: return 338;
- case WEAPON_KATANA: return 339;
- case WEAPON_CHAINSAW: return 341;
- case WEAPON_DILDO: return 321;
- case WEAPON_DILDO2: return 322;
- case WEAPON_VIBRATOR: return 323;
- case WEAPON_VIBRATOR2: return 324;
- case WEAPON_FLOWER: return 325;
- case WEAPON_CANE: return 326;
- case WEAPON_GRENADE: return 342;
- case WEAPON_TEARGAS: return 343;
- case WEAPON_MOLTOV: return 344;
- case WEAPON_COLT45: return 346;
- case WEAPON_SILENCED: return 347;
- case WEAPON_DEAGLE: return 348;
- case WEAPON_SHOTGUN: return 349;
- case WEAPON_SAWEDOFF: return 350;
- case WEAPON_SHOTGSPA: return 351;
- case WEAPON_UZI: return 352;
- case WEAPON_MP5: return 353;
- case WEAPON_AK47: return 355;
- case WEAPON_M4: return 356;
- case WEAPON_TEC9: return 372;
- case WEAPON_RIFLE: return 357;
- case WEAPON_SNIPER: return 358;
- case WEAPON_ROCKETLAUNCHER: return 359;
- case WEAPON_HEATSEEKER: return 360;
- case WEAPON_FLAMETHROWER: return 361;
- case WEAPON_MINIGUN: return 362;
- case WEAPON_SATCHEL: return 363;
- case WEAPON_BOMB: return 364;
- case WEAPON_SPRAYCAN: return 365;
- case WEAPON_FIREEXTINGUISHER: return 366;
- case WEAPON_CAMERA: return 367;
- case 44: return 368;
- case 45: return 369;
- case WEAPON_PARACHUTE: return 371;
- default: return 0;
- }
- return 0;
- }
- stock GetWeaponPickupAmmoDifference(weaponid)
- {
- switch(weaponid)
- {
- case WEAPON_CAMERA: return 36;
- case WEAPON_FIREEXTINGUISHER: return 500;
- case WEAPON_SPRAYCAN: return 500;
- case WEAPON_SATCHEL: return 5;
- case WEAPON_MINIGUN: return 500;
- case WEAPON_FLAMETHROWER: return 100;
- case WEAPON_HEATSEEKER: return 3;
- case WEAPON_ROCKETLAUNCHER: return 4;
- case WEAPON_SNIPER: return 10;
- case WEAPON_RIFLE: return 20;
- case WEAPON_TEC9: return 60;
- case WEAPON_M4: return 80;
- case WEAPON_AK47: return 80;
- case WEAPON_MP5: return 60;
- case WEAPON_UZI: return 60;
- case WEAPON_SHOTGSPA: return 10;
- case WEAPON_SAWEDOFF: return 10;
- case WEAPON_SHOTGUN: return 15;
- case WEAPON_DEAGLE: return 10;
- case WEAPON_SILENCED: return 10;
- case WEAPON_COLT45: return 30;
- case WEAPON_MOLTOV: return 8;
- case WEAPON_TEARGAS: return 8;
- case WEAPON_GRENADE: return 8;
- default: return 1;
- }
- return 1;
- }
- stock GetWeaponAmmunationPrice(weaponid)
- {
- switch(weaponid)
- {
- case WEAPON_GRENADE: return 300;
- case WEAPON_COLT45: return 200;
- case WEAPON_SILENCED: return 600;
- case WEAPON_DEAGLE: return 1200;
- case WEAPON_SHOTGUN: return 600;
- case WEAPON_SAWEDOFF: return 800;
- case WEAPON_SHOTGSPA: return 1200;
- case WEAPON_UZI: return 500;
- case WEAPON_MP5: return 2000;
- case WEAPON_AK47: return 3500;
- case WEAPON_M4: return 4500;
- case WEAPON_TEC9: return 300;
- case WEAPON_RIFLE: return 1000;
- case WEAPON_SNIPER: return 5000;
- case WEAPON_SATCHEL: return 2000;
- default: return 0;
- }
- return 0;
- }
- #if !defined Distance
- stock Float:Distance(Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2)
- return floatsqroot((((x1-x2)*(x1-x2))+((y1-y2)*(y1-y2))+((z1-z2)*(z1-z2))));
- #endif
- stock IsPlayerBuyingInAmmunation(playerid)
- {
- if(interiorsturnedoff)
- return 0;
- if(GetPlayerCameraMode(playerid) != 15)
- return 0;
- if(!GetWeaponAmmunationPrice(GetPlayerWeapon(playerid)))
- return 0;
- static interiorid;
- interiorid = GetPlayerInterior(playerid);
- static
- Float:CameraPositions[3];
- GetPlayerCameraPos(playerid, CameraPositions[0], CameraPositions[1], CameraPositions[2]);
- if(interiorid == 1)
- {
- if(Distance(CameraPositions[0], CameraPositions[1], CameraPositions[2], 296.584991, -38.345001, 1002.236022) > 0.5)
- return 0;
- GetPlayerCameraFrontVector(playerid, CameraPositions[0], CameraPositions[1], CameraPositions[2]);
- if(Distance(CameraPositions[0], CameraPositions[1], CameraPositions[2], -0.083937, -0.952462, -0.292864) > 0.3)
- return 0;
- }
- else if(interiorid == 4)
- {
- if(Distance(CameraPositions[0], CameraPositions[1], CameraPositions[2], 295.819976, -80.656005, 1002.223022) > 0.5)
- return 0;
- GetPlayerCameraFrontVector(playerid, CameraPositions[0], CameraPositions[1], CameraPositions[2]);
- if(Distance(CameraPositions[0], CameraPositions[1], CameraPositions[2], -0.083937, -0.952462, -0.292865) > 0.3)
- return 0;
- }
- else if(interiorid == 6)
- {
- if(Distance(CameraPositions[0], CameraPositions[1], CameraPositions[2], 290.320983, -109.684997, 1002.234008) > 0.5 &&
- Distance(CameraPositions[0], CameraPositions[1], CameraPositions[2], 312.869995, -166.126007, 1000.307006) > 0.5 )
- return 0;
- GetPlayerCameraFrontVector(playerid, CameraPositions[0], CameraPositions[1], CameraPositions[2]);
- if(Distance(CameraPositions[0], CameraPositions[1], CameraPositions[2], -0.083936, -0.952462, -0.292863) > 0.3 &&
- Distance(CameraPositions[0], CameraPositions[1], CameraPositions[2], -0.083938, -0.952461, -0.292867))
- return 0;
- }
- else if(interiorid == 7)
- {
- if(Distance(CameraPositions[0], CameraPositions[1], CameraPositions[2], 308.226989, -141.281005, 1000.307006) > 0.5)
- return 0;
- GetPlayerCameraFrontVector(playerid, CameraPositions[0], CameraPositions[1], CameraPositions[2]);
- if(Distance(CameraPositions[0], CameraPositions[1], CameraPositions[2], -0.083938, -0.952461, -0.292867) > 0.3)
- return 0;
- }
- else
- {
- return 0;
- }
- return 1;
- }
- stock IsPlayerThrowingGrenade(playerid)
- {
- static animid;
- animid = GetPlayerAnimationIndex(playerid);
- if(animid == 644 || animid == 645 || animid == 646)
- return 1;
- return 0;
- }
- stock IsPlayerUsingWeapon(playerid)
- {
- static animid;
- animid = GetPlayerAnimationIndex(playerid);
- if(1167 >= animid >= 1158)
- return 1;
- return 0;
- }
- stock IsPlayerUsingParachute(playerid)
- {
- static animid;
- animid = GetPlayerAnimationIndex(playerid);
- if(979 >= animid >= 958)
- return 1;
- return 0;
- }
- stock GetWeaponSlotID(weaponid)
- {
- switch(weaponid)
- {
- case 0, 1: return 0;
- case 2..9: return 1;
- case 10..15: return 10;
- case 16, 17, 18, 39:return 8;
- case 22..24: return 2;
- case 25..27: return 3;
- case 28,29,32: return 4;
- case 30,31: return 5;
- case 33,34: return 6;
- case 35..38: return 7;
- case 40: return 12;
- case 41..43: return 9;
- case 44..46: return 11;
- default: return -1;
- }
- return -1;
- }
- stock IsPlayerWeaponSlotTaken(playerid, slot)
- {
- static weaponid, ammo;
- GetPlayerWeaponData(playerid, slot, weaponid, ammo);
- if(weaponid || ammo)
- return weaponid;
- return 0;
- }
- stock IsValidPlayerWeapon(playerid, weaponslot)
- {
- if(!PlayerWeapons[playerid][weaponslot])
- return 0;
- if(PlayerWepAmmo[playerid][weaponslot] < 1)
- return 0;
- return PlayerWeapons[playerid][weaponslot];
- }
- stock SetPlayerLegitWeapons(playerid)
- {
- ResetPlayerWeapons(playerid);
- for(new wslot = 0; wslot < 12; wslot++)
- {
- if(!IsValidPlayerWeapon(playerid, wslot))
- continue;
- GivePlayerWeapon(
- playerid,
- PlayerWeapons[playerid][wslot],
- PlayerWepAmmo[playerid][wslot]);
- }
- return 1;
- }
- stock weapons_GivePlayerWeapon(playerid, weaponid, ammo)
- {
- if(!weaponid)
- return 0;
- if(ammo > MAX_WEAPON_AMMO) { ammo = MAX_WEAPON_AMMO; }
- static slot;
- slot = GetWeaponSlotID(weaponid);
- if(IsPlayerWeaponSlotTaken(playerid, slot) == weaponid)
- {
- PlayerWepAmmo[playerid][slot] += ammo;
- if(PlayerWepAmmo[playerid][slot] > MAX_WEAPON_AMMO) { PlayerWepAmmo[playerid][slot] = MAX_WEAPON_AMMO; }
- }
- else
- {
- PlayerWeapons[playerid][slot] = weaponid;
- PlayerWepAmmo[playerid][slot] = ammo;
- }
- LastPlayerAmmo[playerid] = ammo;
- return GivePlayerWeapon(playerid, weaponid, ammo);
- }
- stock RemovePlayerWeapon(playerid, weaponslot)
- {
- ResetPlayerWeapons(playerid);
- PlayerWeapons[playerid][weaponslot] = 0;
- PlayerWepAmmo[playerid][weaponslot] = 0;
- SetPlayerLegitWeapons(playerid);
- return 1;
- }
- stock weapons_GetPlayerWeapon(playerid)
- {
- static weaponid;
- weaponid = GetPlayerWeapon(playerid);
- if(IsValidPlayerWeapon(playerid, GetWeaponSlotID(weaponid)) == weaponid)
- {
- return weaponid;
- }
- return 0;
- }
- stock weapons_GetPlayerAmmo(playerid)
- {
- static weaponid;
- weaponid = weapons_GetPlayerWeapon(playerid);
- if(weaponid)
- {
- return PlayerWepAmmo[playerid][GetWeaponSlotID(weaponid)];
- }
- return 0;
- }
- stock weapons_SetPlayerAmmo(playerid, weaponslot, ammo)
- {
- if(IsValidPlayerWeapon(playerid, weaponslot))
- {
- if(GetPlayerWeapon(playerid) == PlayerWepAmmo[playerid][weaponslot])
- {
- LastPlayerAmmo [playerid] = 0;
- }
- PlayerWepAmmo[playerid][weaponslot] = ammo;
- SetPlayerAmmo(playerid, weaponslot, ammo);
- return 1;
- }
- return 0;
- }
- stock weapons_ResetPlayerWeapons(playerid)
- {
- ResetPlayerWeapons(playerid);
- for(new slot = 0; slot < 12; slot++)
- {
- PlayerWeapons[playerid][slot] = 0;
- PlayerWepAmmo[playerid][slot] = 0;
- }
- return 1;
- }
- /*
- I forgot the original creator for this code but it's very useful.
- Effectively abstracts the basic checking for tick count intervals with some
- extra code that compensates for integer overflowing from GetTickCount if the
- server machine has been on for over 2,147,483,647 milliseconds.
- */
- stock intdiffabs(tick1, tick2)
- {
- if(tick1 > tick2)
- {
- new value = (tick1 - tick2);
- return value < 0 ? -value : value;
- }
- else
- {
- new value = (tick1 - tick2);
- return value < 0 ? -value : value;
- }
- }
- stock GetTickCountDifference(a, b)
- {
- if ((a < 0) && (b > 0))
- {
- new dist;
- dist = intdiffabs(a, b);
- if(dist > 2147483647)
- return intdiffabs(a - 2147483647, b - 2147483647);
- else
- return dist;
- }
- return intdiffabs(a, b);
- }
- #if defined _ALS_DisableInteriorEnterExits
- #undef DisableInteriorEnterExits
- #else
- #define _ALS_DisableInteriorEnterExits
- #endif
- #define DisableInteriorEnterExits acwep_DisableInteriorEnterExits
- #if defined _ALS_AddStaticPickup
- #undef AddStaticPickup
- #else
- #define _ALS_AddStaticPickup
- #endif
- #define AddStaticPickup weapons_AddStaticPickup
- #if defined _ALS_CreatePickup
- #undef CreatePickup
- #else
- #define _ALS_CreatePickup
- #endif
- #define CreatePickup weapons_CreatePickup
- #if defined _ALS_AddPlayerClass
- #undef AddPlayerClass
- #else
- #define _ALS_AddPlayerClass
- #endif
- #define AddPlayerClass weapons_AddPlayerClass
- #if defined _ALS_AddPlayerClassEx
- #undef AddPlayerClassEx
- #else
- #define _ALS_AddPlayerClassEx
- #endif
- #define AddPlayerClassEx weapons_AddPlayerClassEx
- #if defined _ALS_SetSpawnInfo
- #undef SetSpawnInfo
- #else
- #define _ALS_SetSpawnInfo
- #endif
- #define SetSpawnInfo weapons_SetSpawnInfo
- #if defined _ALS_GivePlayerWeapon
- #undef GivePlayerWeapon
- #else
- #define _ALS_GivePlayerWeapon
- #endif
- #define GivePlayerWeapon weapons_GivePlayerWeapon
- #if defined _ALS_GetPlayerWeapon
- #undef GetPlayerWeapon
- #else
- #define _ALS_GetPlayerWeapon
- #endif
- #define GetPlayerWeapon weapons_GetPlayerWeapon
- #if defined _ALS_GetPlayerAmmo
- #undef GetPlayerAmmo
- #else
- #define _ALS_GetPlayerAmmo
- #endif
- #define GetPlayerAmmo weapons_GetPlayerAmmo
- #if defined _ALS_SetPlayerAmmo
- #undef SetPlayerAmmo
- #else
- #define _ALS_SetPlayerAmmo
- #endif
- #define SetPlayerAmmo weapons_SetPlayerAmmo
- #if defined _ALS_ResetPlayerWeapons
- #undef ResetPlayerWeapons
- #else
- #define _ALS_ResetPlayerWeapons
- #endif
- #define ResetPlayerWeapons weapons_ResetPlayerWeapons
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement