Mensajes: 13
Temas: 5
Registro en: Jul 2017
Reputación:
0
Que tal compañeros de la comunidad amxmodx, escribo porque tengo un problema tengo una tienda de extra item mediante natives, pero al comprar un arma me queda el arma principal conque spawneo en el server, osea me quedan 2 armas primarias la del extra item y la normal, y quisiera saber como hacer para que cuando compre un extra item el arma primaria sea soltada.
Gracias.
Mensajes: 6,664
Temas: 81
Registro en: Jan 2014
Reputación:
68
Código PHP: const PRIMARY_WEAPONS_BIT_SUM = (1<<CSW_SCOUT)|(1<<CSW_XM1014)|(1<<CSW_MAC10)|(1<<CSW_AUG)|(1<<CSW_UMP45)|(1<<CSW_SG550)|(1<<CSW_GALIL)|(1<<CSW_FAMAS)|(1<<CSW_AWP)|(1<<CSW_MP5NAVY)|(1<<CSW_M249)|(1<<CSW_M3)|(1<<CSW_M4A1)|(1<<CSW_TMP)|(1<<CSW_G3SG1)|(1<<CSW_SG552)|(1<<CSW_AK47)|(1<<CSW_P90) const SECONDARY_WEAPONS_BIT_SUM = (1<<CSW_P228)|(1<<CSW_ELITE)|(1<<CSW_FIVESEVEN)|(1<<CSW_USP)|(1<<CSW_GLOCK18)|(1<<CSW_DEAGLE) const PEV_ADDITIONAL_AMMO = pev_iuser1
stock drop_weapons(id, dropwhat) { // Get user weapons static weapons[32], num, i, weaponid num = 0 // reset passed weapons count (bugfix) get_user_weapons(id, weapons, num) // Loop through them and drop primaries or secondaries for (i = 0; i < num; i++) { // Prevent re-indexing the array weaponid = weapons[i] if ((dropwhat == 1 && ((1<<weaponid) & PRIMARY_WEAPONS_BIT_SUM)) || (dropwhat == 2 && ((1<<weaponid) & SECONDARY_WEAPONS_BIT_SUM))) { // Get weapon entity static wname[32], weapon_ent get_weaponname(weaponid, wname, charsmax(wname)) weapon_ent = fm_find_ent_by_owner(-1, wname, id) // Hack: store weapon bpammo on PEV_ADDITIONAL_AMMO set_pev(weapon_ent, PEV_ADDITIONAL_AMMO, cs_get_user_bpammo(id, weaponid)) // Player drops the weapon and looses his bpammo engclient_cmd(id, "drop", wname) cs_set_user_bpammo(id, weaponid, 0) } } }
stock fm_find_ent_by_owner(entity, const classname[], owner) { while ((entity = engfunc(EngFunc_FindEntityByString, entity, "classname", classname)) && pev(entity, pev_owner) != owner) { /* keep looping */ } return entity; }
Sacado del zp, creo
► NO DOY AYUDA VIA MENSAJE PRIVADO ◄
* Si requieres algún servicio de pago puedes contactarme vía MP o en mi facebook
Mensajes: 13
Temas: 5
Registro en: Jul 2017
Reputación:
0
(22/08/2017, 03:16 PM)kikizon2 escribió: Código PHP: const PRIMARY_WEAPONS_BIT_SUM = (1<<CSW_SCOUT)|(1<<CSW_XM1014)|(1<<CSW_MAC10)|(1<<CSW_AUG)|(1<<CSW_UMP45)|(1<<CSW_SG550)|(1<<CSW_GALIL)|(1<<CSW_FAMAS)|(1<<CSW_AWP)|(1<<CSW_MP5NAVY)|(1<<CSW_M249)|(1<<CSW_M3)|(1<<CSW_M4A1)|(1<<CSW_TMP)|(1<<CSW_G3SG1)|(1<<CSW_SG552)|(1<<CSW_AK47)|(1<<CSW_P90) const SECONDARY_WEAPONS_BIT_SUM = (1<<CSW_P228)|(1<<CSW_ELITE)|(1<<CSW_FIVESEVEN)|(1<<CSW_USP)|(1<<CSW_GLOCK18)|(1<<CSW_DEAGLE) const PEV_ADDITIONAL_AMMO = pev_iuser1
stock drop_weapons(id, dropwhat) { // Get user weapons static weapons[32], num, i, weaponid num = 0 // reset passed weapons count (bugfix) get_user_weapons(id, weapons, num) // Loop through them and drop primaries or secondaries for (i = 0; i < num; i++) { // Prevent re-indexing the array weaponid = weapons[i] if ((dropwhat == 1 && ((1<<weaponid) & PRIMARY_WEAPONS_BIT_SUM)) || (dropwhat == 2 && ((1<<weaponid) & SECONDARY_WEAPONS_BIT_SUM))) { // Get weapon entity static wname[32], weapon_ent get_weaponname(weaponid, wname, charsmax(wname)) weapon_ent = fm_find_ent_by_owner(-1, wname, id) // Hack: store weapon bpammo on PEV_ADDITIONAL_AMMO set_pev(weapon_ent, PEV_ADDITIONAL_AMMO, cs_get_user_bpammo(id, weaponid)) // Player drops the weapon and looses his bpammo engclient_cmd(id, "drop", wname) cs_set_user_bpammo(id, weaponid, 0) } } }
stock fm_find_ent_by_owner(entity, const classname[], owner) { while ((entity = engfunc(EngFunc_FindEntityByString, entity, "classname", classname)) && pev(entity, pev_owner) != owner) { /* keep looping */ } return entity; }
Sacado del zp, creo
Thanks, eso lo coloco en el sma de tienda noh?
|