Mensajes: 417
Temas: 53
Registro en: May 2014
29/07/2014, 01:14 PM
Hola gente, como les va ? Despues de buscar, e intentar de varias formas, no logro hacerlo de la forma correcta u.u . Lo que quiero hacer, es que al tirar el arma, se le setee el numero de la variable que tenia el jugador a la entidad del arma que queda en el piso, y al recoger esa arma, al jugador que la agarro que se le ponga la variable en el numero que tenia el arma/entidad del piso. Paso el code a ver si me pueden ayudar :c .
Código PHP: // Forward Set Model public fw_SetModel(entity, const model[]) { // We don't care if (strlen(model) < 8) return; // Remove weapons? if (get_pcvar_float(cvar_removedropped) > 0.0) { // Get entity's classname static classname[10] pev(entity, pev_classname, classname, charsmax(classname)) // Check if it's a weapon box if (equal(classname, "weaponbox")) { g_arma_prim[entity] = g_arma_prim[pev(entity, pev_owner)] // They get automatically removed when thinking set_pev(entity, pev_nextthink, get_gametime() + get_pcvar_float(cvar_removedropped)) return; } } // code code.. // code code.. }
Código PHP: // Ham Weapon Touch Forward public fw_TouchWeapon(weapon, id) { // Not a player if (!is_user_valid_connected(id)) return HAM_IGNORED; // Dont pickup weapons if zombie or survivor (+PODBot MM fix) if (g_zombie[id] || (g_survivor[id] && !flag_get(g_isbot, id))) return HAM_SUPERCEDE; g_arma_prim[id] = g_arma_prim[weapon] return HAM_IGNORED; }
Cuando dropeo el arma, y toco la entidad del arma que quedo en el piso,
me sale Run time error 4: index out of bounds en logs, y no puedo agarrar el arma
Mensajes: 1,616
Temas: 19
Registro en: Oct 2013
Reputación:
16
29/07/2014, 01:53 PM
(Última modificación: 29/07/2014, 01:54 PM por alan_el_more.)
Código PHP: //Guardar número a X entidad //[Fakemeta] set_pev(ent, pev_iuser3, numero_a_guardar) //[Engine] entity_set_int(ent, EV_INT_iuser4, numero_a_guardar)
//Cargar número a X entidad //[Fakemeta] pev(ent, pev_iuser4) //[Engine] entity_get_int(ent, EV_INT_iuser4)
Ni te molestes en enviarme un mensaje privado para pedirme ayuda porque NO lo voy a contestar.
Gracias por su atención.
Mensajes: 417
Temas: 53
Registro en: May 2014
29/07/2014, 02:08 PM
(Última modificación: 29/07/2014, 02:12 PM por Ipolito.)
(29/07/2014, 01:53 PM)alan_el_more escribió: Código PHP: //Guardar número a X entidad //[Fakemeta] set_pev(ent, pev_iuser3, numero_a_guardar) //[Engine] entity_set_int(ent, EV_INT_iuser4, numero_a_guardar)
//Cargar número a X entidad //[Fakemeta] pev(ent, pev_iuser4) //[Engine] entity_get_int(ent, EV_INT_iuser4)
Código PHP: // Forward Set Model public fw_SetModel(entity, const model[]) { // We don't care if (strlen(model) < 8) return; // Remove weapons? if (get_pcvar_float(cvar_removedropped) > 0.0) { // Get entity's classname static classname[10] pev(entity, pev_classname, classname, charsmax(classname)) // Check if it's a weapon box if (equal(classname, "weaponbox")) { set_pev(entity, pev_iuser3, g_arma_prim[pev(entity, pev_owner)]) set_pev(entity, pev_nextthink, get_gametime() + get_pcvar_float(cvar_removedropped)) return; } } }
public fw_TouchWeapon(weapon, id) { // Not a player if (!is_user_valid_connected(id)) return HAM_IGNORED; //pev(weapon, pev_iuser4) g_arma_prim[id] = g_arma_prim[pev(weapon, pev_iuser4)] replace_weapon_models(id, weapon) // Dont pickup weapons if zombie or survivor (+PODBot MM fix) if (g_zombie[id] || (g_survivor[id] && !flag_get(g_isbot, id))) return HAM_SUPERCEDE; return HAM_IGNORED; }
Lo que hice fue eso, pero no funciona ._., al agarrar el arma, me tendria que setear el model, el daño, etc..
Haciendolo asi, la variable g_arma_prim, queda siempre en 0 :/
Mensajes: 1,616
Temas: 19
Registro en: Oct 2013
Reputación:
16
Hace estos cambios y debería funcionar
Código PHP: g_arma_prim [id ] = g_arma_prim [ pev (weapon , pev_iuser4 )]
->
Código PHP: g_arma_prim [id ] = pev(weapon, pev_iuser4 )
Código PHP: set_pev (entity , pev_iuser3 , g_arma_prim [pev (entity , pev_owner )])
->
Código PHP: set_pev (entity , pev_iuser4 , g_arma_prim [pev (entity , pev_owner )])
Ni te molestes en enviarme un mensaje privado para pedirme ayuda porque NO lo voy a contestar.
Gracias por su atención.
Mensajes: 417
Temas: 53
Registro en: May 2014
(29/07/2014, 02:18 PM)alan_el_more escribió: Hace estos cambios y debería funcionar
Código PHP: g_arma_prim [id ] = g_arma_prim [ pev (weapon , pev_iuser4 )]
->
Código PHP: g_arma_prim [id ] = pev(weapon, pev_iuser4 )
Código PHP: set_pev (entity , pev_iuser3 , g_arma_prim [pev (entity , pev_owner )])
->
Código PHP: set_pev (entity , pev_iuser4 , g_arma_prim [pev (entity , pev_owner )])
Me sigue dando 0 lpm jajja :S
Código PHP: // Forward Set Model public fw_SetModel(entity, const model[]) { // We don't care if (strlen(model) < 8) return; // Remove weapons? if (get_pcvar_float(cvar_removedropped) > 0.0) { // Get entity's classname static classname[10] pev(entity, pev_classname, classname, charsmax(classname)) // Check if it's a weapon box if (equal(classname, "weaponbox")) { //set_pev(entity, pev_iuser3, g_arma_prim[pev(entity, pev_owner)]) set_pev(entity, pev_iuser4, g_arma_prim[pev(entity , pev_owner)]) set_pev(entity, pev_nextthink, get_gametime() + get_pcvar_float(cvar_removedropped)) return; } } //code.. // code }
public fw_TouchWeapon(weapon, id) { // Not a player if (!is_user_valid_connected(id)) return HAM_IGNORED; //pev(weapon, pev_iuser4) g_arma_prim[id] = pev(weapon, pev_iuser4) replace_weapon_models(id, weapon) // Dont pickup weapons if zombie or survivor (+PODBot MM fix) if (g_zombie[id] || (g_survivor[id] && !flag_get(g_isbot, id))) return HAM_SUPERCEDE; return HAM_IGNORED; }
Mensajes: 1,616
Temas: 19
Registro en: Oct 2013
Reputación:
16
Hace los famosos "debug prints".
Mostra los valores en el chat/consola de los valores g_arma_prim y pev (entity , pev_owner ) en las dos funciones y fijate que valores muestra.
Ni te molestes en enviarme un mensaje privado para pedirme ayuda porque NO lo voy a contestar.
Gracias por su atención.
Mensajes: 417
Temas: 53
Registro en: May 2014
(29/07/2014, 02:46 PM)alan_el_more escribió: Hace los famosos "debug prints".
Mostra los valores en el chat/consola de los valores g_arma_prim y pev (entity , pev_owner ) en las dos funciones y fijate que valores muestra.
Ya los hice, y da 0.. de las 2
Mensajes: 189
Temas: 6
Registro en: Jan 2014
Reputación:
6
(29/07/2014, 03:52 PM)Ipolito escribió: (29/07/2014, 02:46 PM)alan_el_more escribió: Hace los famosos "debug prints".
Mostra los valores en el chat/consola de los valores g_arma_prim y pev (entity , pev_owner ) en las dos funciones y fijate que valores muestra.
Ya los hice, y da 0.. de las 2
Y en algun momento les seteas un valor distinto de cero?
Mensajes: 417
Temas: 53
Registro en: May 2014
29/07/2014, 06:47 PM
(Última modificación: 29/07/2014, 10:46 PM por Ipolito.)
(29/07/2014, 06:05 PM)NikKOo31 escribió: (29/07/2014, 03:52 PM)Ipolito escribió: (29/07/2014, 02:46 PM)alan_el_more escribió: Hace los famosos "debug prints".
Mostra los valores en el chat/consola de los valores g_arma_prim y pev (entity , pev_owner ) en las dos funciones y fijate que valores muestra.
Ya los hice, y da 0.. de las 2
Y en algun momento les seteas un valor distinto de cero?
Si, cuando el jugador compra el arma, en la funcion buy_primary_weapons
Código PHP: // Buy Primary Weapon buy_primary_weapon(id, selection) { // Drop previous weapons drop_weapons(id, 1) drop_weapons(id, 2) // Strip off from weapons fm_strip_user_weapons(id) fm_give_item(id, "weapon_knife") g_arma_prim[id] = selection // guardamos el item en esta variable // Give the new weapon give_item(id, WPN_CSNAME[selection]) ExecuteHamB(Ham_GiveAmmo, id, MAXBPAMMO[WPN_IDS[selection]], AMMOTYPE[WPN_IDS[selection]], MAXBPAMMO[WPN_IDS[selection]]) // Weapons bought g_canbuy[id] = false // Give additional items fm_give_item(id, "weapon_hegrenade") fm_give_item(id, "weapon_flashbang") fm_give_item(id, "weapon_smokegrenade") }
Mensajes: 189
Temas: 6
Registro en: Jan 2014
Reputación:
6
(29/07/2014, 06:47 PM)Ipolito escribió: (29/07/2014, 06:05 PM)NikKOo31 escribió: (29/07/2014, 03:52 PM)Ipolito escribió: (29/07/2014, 02:46 PM)alan_el_more escribió: Hace los famosos "debug prints".
Mostra los valores en el chat/consola de los valores g_arma_prim y pev (entity , pev_owner ) en las dos funciones y fijate que valores muestra.
Ya los hice, y da 0.. de las 2
Y en algun momento les seteas un valor distinto de cero?
Si, cuando el jugador compra el arma, en la funcion buy_primary_weapons
Otra pregunta tonta.. Qe tiempo tenes configurado en la cvar para qe desaparezcan las armas?
Mensajes: 417
Temas: 53
Registro en: May 2014
(29/07/2014, 07:15 PM)NikKOo31 escribió: (29/07/2014, 06:47 PM)Ipolito escribió: (29/07/2014, 06:05 PM)NikKOo31 escribió: (29/07/2014, 03:52 PM)Ipolito escribió: (29/07/2014, 02:46 PM)alan_el_more escribió: Hace los famosos "debug prints".
Mostra los valores en el chat/consola de los valores g_arma_prim y pev (entity , pev_owner ) en las dos funciones y fijate que valores muestra.
Ya los hice, y da 0.. de las 2
Y en algun momento les seteas un valor distinto de cero?
Si, cuando el jugador compra el arma, en la funcion buy_primary_weapons
Otra pregunta tonta.. Qe tiempo tenes configurado en la cvar para qe desaparezcan las armas?
En 0, osea, para que no desaparezcan
Mensajes: 1,616
Temas: 19
Registro en: Oct 2013
Reputación:
16
Por eso no te funciona.
Lee la siguiente línea y te vas a dar cuenta.
Código PHP: if(get_pcvar_float(cvar_removedropped) > 0.0) { // }
Ni te molestes en enviarme un mensaje privado para pedirme ayuda porque NO lo voy a contestar.
Gracias por su atención.
Mensajes: 180
Temas: 26
Registro en: Oct 2013
Reputación:
0
30/07/2014, 05:27 AM
(Última modificación: 30/07/2014, 05:36 AM por exodisto.)
Código PHP: if (get_pcvar_float(cvar_removedropped) > 0.0) { // Get entity's classname static classname[10] pev(entity, pev_classname, classname, charsmax(classname)) // Check if it's a weapon box if (equal(classname, "weaponbox")) { //set_pev(entity, pev_iuser3, g_arma_prim[pev(entity, pev_owner)]) set_pev(entity, pev_iuser4, g_arma_prim[pev(entity , pev_owner)]) set_pev(entity, pev_nextthink, get_gametime() + get_pcvar_float(cvar_removedropped)) return; } }
->
Código PHP: // Get entity's classname static classname[10] pev(entity, pev_classname, classname, charsmax(classname)) // Check if it's a weapon box if (equal(classname, "weaponbox")) { // They get automatically removed when thinking set_pev(entity, pev_iuser4, g_arma_prim[pev(entity , pev_owner)]) return; }
Me ayudaron a entender la teoria del big bang
Mensajes: 417
Temas: 53
Registro en: May 2014
30/07/2014, 06:42 AM
(Última modificación: 30/07/2014, 08:16 AM por Ipolito.)
(30/07/2014, 05:27 AM)exodisto escribió: Código PHP: if (get_pcvar_float(cvar_removedropped) > 0.0) { // Get entity's classname static classname[10] pev(entity, pev_classname, classname, charsmax(classname)) // Check if it's a weapon box if (equal(classname, "weaponbox")) { //set_pev(entity, pev_iuser3, g_arma_prim[pev(entity, pev_owner)]) set_pev(entity, pev_iuser4, g_arma_prim[pev(entity , pev_owner)]) set_pev(entity, pev_nextthink, get_gametime() + get_pcvar_float(cvar_removedropped)) return; } }
->
Código PHP: // Get entity's classname static classname[10] pev(entity, pev_classname, classname, charsmax(classname)) // Check if it's a weapon box if (equal(classname, "weaponbox")) { // They get automatically removed when thinking set_pev(entity, pev_iuser4, g_arma_prim[pev(entity , pev_owner)]) return; }
Me ayudaron a entender la teoria del big bang
Listo, lo puse asi, pero ahora hay otro problema O.o , aveces me setea la variable g_arma_prim en el numero que tenia el arma que tire, y aveces no. No se como explicarme bien, a ver si asi me entienden.
Tiro la m4a1 comun (arma numero 4, g_arma_prim[id] = 4)
Luego tiro la m4a1 deluxe (arma numero 5, g_arma_prim[id] = 5)
Recogo la m4a1 deluxe, me pone el model, atributos, perfecto.
Ahora, tiro la m4a1 deluxe, y agarro la m4a1 comun, per.. se me ponen los atributos de la m4a1 deluxe en la m4a1 comun, es decir, que la m4a1 comun paso a ser una m4a1 deluxe, se entiende ? D:
Otra cosa, por ej, estoy parado arriba de la m4a1 comun, si tengo la m4a1 deluxe y la tiro, al agarrar la m4a1 comun pasa a ser automaticamente m4a1 deluxe xD, pasa con toda las armas D:
Mensajes: 2,571
Temas: 40
Registro en: Feb 2014
Reputación:
72
Has que al dropear una M4A1 (Sea deluxe o no) la variable g_arma_prim[id] se vuelva 4, y si recoge una M4A1 deluxe se cambiará a 5, si recoge una normal no pasará nada ¿Se supone?
Mensajes: 1,616
Temas: 19
Registro en: Oct 2013
Reputación:
16
Yo haría esto:
Código PHP: // Get entity's classname static classname [ 10] pev ( entity, pev_classname , classname , charsmax ( classname)) // Check if it's a weapon box if ( equal ( classname, "weaponbox" )) { static iOwner iOwner = pev( entity , pev_owner ) // They get automatically removed when thinking set_pev ( entity, pev_iuser4 , g_arma_prim [ iOwner])
g_arma_prim[iOwner] = -1 return; }
Igual, también habría que chequear que el arma sea primaria
Ni te molestes en enviarme un mensaje privado para pedirme ayuda porque NO lo voy a contestar.
Gracias por su atención.
Mensajes: 417
Temas: 53
Registro en: May 2014
(30/07/2014, 10:34 AM)Mario AR. escribió: Has que al dropear una M4A1 (Sea deluxe o no) la variable g_arma_prim[id] se vuelva 4, y si recoge una M4A1 deluxe se cambiará a 5, si recoge una normal no pasará nada ¿Se supone?
Y si tengo 37 armas diferentes como tendria que hacerlo (?
No lo puedo hacer andar , intente un monton de formas diferentes u.u
Mensajes: 189
Temas: 6
Registro en: Jan 2014
Reputación:
6
30/07/2014, 11:28 AM
(Última modificación: 30/07/2014, 11:31 AM por NikKOo31.)
(29/07/2014, 10:49 PM)alan_el_more escribió: Por eso no te funciona.
Lee la siguiente línea y te vas a dar cuenta.
Código PHP: if(get_pcvar_float(cvar_removedropped) > 0.0) { // }
Yo me di cuenta primero
Edit* para solucionar tu problema, hookea el drop y limpia la variable del usuario
Mensajes: 417
Temas: 53
Registro en: May 2014
30/07/2014, 11:59 AM
(Última modificación: 30/07/2014, 12:02 PM por Ipolito.)
(30/07/2014, 10:59 AM)alan_el_more escribió: Yo haría esto:
Código PHP: // Get entity's classname static classname [ 10] pev ( entity, pev_classname , classname , charsmax ( classname)) // Check if it's a weapon box if ( equal ( classname, "weaponbox" )) { static iOwner iOwner = pev( entity , pev_owner ) // They get automatically removed when thinking set_pev ( entity, pev_iuser4 , g_arma_prim [ iOwner])
g_arma_prim[iOwner] = -1 return; }
Igual, también habría que chequear que el arma sea primaria
Ahora lo hice asi..
Código PHP: // Forward Set Model public fw_SetModel(entity, const model[]) { static classname[10] pev(entity, pev_classname, classname, charsmax(classname)) // Check if it's a weapon box if (equal(classname, "weaponbox")) { static iOwner iOwner = pev( entity , pev_owner ) // They get automatically removed when thinking set_pev(entity, pev_iuser4 , g_arma_prim[iOwner]) g_arma_prim[iOwner] = -1 return; } // code code }
public fw_TouchWeapon(weapon, id) { // Not a player if (!is_user_valid_connected(id)) return HAM_IGNORED; //pev(weapon, pev_iuser4) if(get_weapon_type(cs_get_weaponbox_id(weapon)) == ITEM_PRIMARY) { g_arma_prim[id] = pev(weapon, pev_iuser4) } //replace_weapon_models(id, weapon) // Dont pickup weapons if zombie or survivor (+PODBot MM fix) if (g_zombie[id] || (g_survivor[id] && !flag_get(g_isbot, id))) return HAM_SUPERCEDE; return HAM_IGNORED; }
get_weapon_type(weapon) { new bitweap = (1<<weapon) if(bitweap & ITEM_PRIMARY_BITSUM) return ITEM_PRIMARY; else if (bitweap & ITEM_SECONDARY_BITSUM) return ITEM_SECONDARY; else if (weapon == CSW_KNIFE) return ITEM_MELEE; else if (bitweap & ITEM_BOMB_BITSUM) return ITEM_BOMB; else return ITEM_UNKNOWN; return HAM_IGNORED; }
// Gets the weapon id from a weaponbox by ConnorMcLeod (only works for CS) (returns in CSW_* constants) stock cs_get_weaponbox_id(weaponbox_ent) { if(pev_valid(weaponbox_ent) != 2) return -1; new weapon for(new i = 1; i <= 5; i++) { weapon = get_pdata_cbase(weaponbox_ent, m_rgpPlayerItems_CWeaponBox[i], 4) if(weapon > 0) return cs_get_weapon_id(weapon); } return 0; }
No me funciono asi :/
(30/07/2014, 11:28 AM)NikKOo31 escribió: (29/07/2014, 10:49 PM)alan_el_more escribió: Por eso no te funciona.
Lee la siguiente línea y te vas a dar cuenta.
Código PHP: if(get_pcvar_float(cvar_removedropped) > 0.0) { // }
Yo me di cuenta primero
Edit* para solucionar tu problema, hookea el drop y limpia la variable del usuario
Si jajajajja
Mensajes: 1,616
Temas: 19
Registro en: Oct 2013
Reputación:
16
1- fw_SetModel quedaría así
Código PHP: public fw_SetModel(entity, const model[]) { static classname[10] pev(entity, pev_classname, classname, charsmax(classname)) // Check if it's a weapon box if (equal(classname, "weaponbox")) { set_pev(entity, pev_iuser4 , g_arma_prim[pev( entity , pev_owner )]+1) return; } // code code }
2- Busca la funcion clcmd_drop y seguramente tendrás algo así, dependiendo de la versión que uses
Código PHP: public clcmd_drop(id) { // Survivor should stick with its weapon if (g_survivor[id] || g_currentweapon[id] == CSW_C4) return PLUGIN_HANDLED; return PLUGIN_CONTINUE; }
Agregale esto:
Código PHP: if((1<<get_user_weapon(id)) & PRIMARY_WEAPONS_BIT_SUM) g_arma_prim[id] = -1
Te quedaría así:
Código PHP: public clcmd_drop(id) { // Survivor should stick with its weapon if (g_survivor[id] || g_currentweapon[id] == CSW_C4) return PLUGIN_HANDLED; if((1<<get_user_weapon(id)) & PRIMARY_WEAPONS_BIT_SUM) g_arma_prim[id] = -1 return PLUGIN_CONTINUE; }
3- fw_TouchWeapon quedaría así
Código PHP: public fw_TouchWeapon(weapon, id) { // Not a player if (!is_user_valid_connected(id)) return HAM_IGNORED; // Dont pickup weapons if zombie or survivor (+PODBot MM fix) if (g_zombie[id] || (g_survivor[id] && !flag_get(g_isbot, id))) return HAM_SUPERCEDE; static iNum;iNum = pev(weapon, pev_iuser4) if(iNum > 0) g_arma_prim[id] = iNum return HAM_IGNORED; }
Ni te molestes en enviarme un mensaje privado para pedirme ayuda porque NO lo voy a contestar.
Gracias por su atención.
Mensajes: 417
Temas: 53
Registro en: May 2014
30/07/2014, 01:03 PM
(Última modificación: 30/07/2014, 01:07 PM por Ipolito.)
(30/07/2014, 12:19 PM)alan_el_more escribió: 1- fw_SetModel quedaría así
Código PHP: public fw_SetModel(entity, const model[]) { static classname[10] pev(entity, pev_classname, classname, charsmax(classname)) // Check if it's a weapon box if (equal(classname, "weaponbox")) { set_pev(entity, pev_iuser4 , g_arma_prim[pev( entity , pev_owner )]+1) return; } // code code }
2- Busca la funcion clcmd_drop y seguramente tendrás algo así, dependiendo de la versión que uses
Código PHP: public clcmd_drop(id) { // Survivor should stick with its weapon if (g_survivor[id] || g_currentweapon[id] == CSW_C4) return PLUGIN_HANDLED; return PLUGIN_CONTINUE; }
Agregale esto:
Código PHP: if((1<<get_user_weapon(id)) & PRIMARY_WEAPONS_BIT_SUM) g_arma_prim[id] = -1
Te quedaría así:
Código PHP: public clcmd_drop(id) { // Survivor should stick with its weapon if (g_survivor[id] || g_currentweapon[id] == CSW_C4) return PLUGIN_HANDLED; if((1<<get_user_weapon(id)) & PRIMARY_WEAPONS_BIT_SUM) g_arma_prim[id] = -1 return PLUGIN_CONTINUE; }
3- fw_TouchWeapon quedaría así
Código PHP: public fw_TouchWeapon(weapon, id) { // Not a player if (!is_user_valid_connected(id)) return HAM_IGNORED; // Dont pickup weapons if zombie or survivor (+PODBot MM fix) if (g_zombie[id] || (g_survivor[id] && !flag_get(g_isbot, id))) return HAM_SUPERCEDE; static iNum;iNum = pev(weapon, pev_iuser4) if(iNum > 0) g_arma_prim[id] = iNum return HAM_IGNORED; }
Lo puse tal cual me lo pasaste y ahora pasa esto u.u .
No se si al dropear el arma, o al agarrarla, te setea la variable g_arma_prim en -1, y queda asi.
Osea, al agarrar el arma no te setea la variable en el numero que se guardo en el arma :S .
PD: Y me sale esto en logs
L 07/30/2014 - 13:00:32: [AMXX] Run time error 4: index out of bounds
L 07/30/2014 - 13:00:32: [AMXX] [0] new land.sma::replace_weapon_models (line 9246)
L 07/30/2014 - 13:00:32: [AMXX] [1] new land.sma::fw_Item_Deploy_Post (line 3047)
L 07/30/2014 - 13:00:33: [AMXX] Displaying debug trace (plugin "zombie_plague40.amxx")
Mensajes: 189
Temas: 6
Registro en: Jan 2014
Reputación:
6
(30/07/2014, 01:03 PM)Ipolito escribió: (30/07/2014, 12:19 PM)alan_el_more escribió: 1- fw_SetModel quedaría así
Código PHP: public fw_SetModel(entity, const model[]) { static classname[10] pev(entity, pev_classname, classname, charsmax(classname)) // Check if it's a weapon box if (equal(classname, "weaponbox")) { set_pev(entity, pev_iuser4 , g_arma_prim[pev( entity , pev_owner )]+1) return; } // code code }
2- Busca la funcion clcmd_drop y seguramente tendrás algo así, dependiendo de la versión que uses
Código PHP: public clcmd_drop(id) { // Survivor should stick with its weapon if (g_survivor[id] || g_currentweapon[id] == CSW_C4) return PLUGIN_HANDLED; return PLUGIN_CONTINUE; }
Agregale esto:
Código PHP: if((1<<get_user_weapon(id)) & PRIMARY_WEAPONS_BIT_SUM) g_arma_prim[id] = -1
Te quedaría así:
Código PHP: public clcmd_drop(id) { // Survivor should stick with its weapon if (g_survivor[id] || g_currentweapon[id] == CSW_C4) return PLUGIN_HANDLED; if((1<<get_user_weapon(id)) & PRIMARY_WEAPONS_BIT_SUM) g_arma_prim[id] = -1 return PLUGIN_CONTINUE; }
3- fw_TouchWeapon quedaría así
Código PHP: public fw_TouchWeapon(weapon, id) { // Not a player if (!is_user_valid_connected(id)) return HAM_IGNORED; // Dont pickup weapons if zombie or survivor (+PODBot MM fix) if (g_zombie[id] || (g_survivor[id] && !flag_get(g_isbot, id))) return HAM_SUPERCEDE; static iNum;iNum = pev(weapon, pev_iuser4) if(iNum > 0) g_arma_prim[id] = iNum return HAM_IGNORED; }
Lo puse tal cual me lo pasaste y ahora pasa esto u.u .
No se si al dropear el arma, o al agarrarla, te setea la variable g_arma_prim en -1, y queda asi.
Osea, al agarrar el arma no te setea la variable en el numero que se guardo en el arma :S .
PD: Y me sale esto en logs
L 07/30/2014 - 13:00:32: [AMXX] Run time error 4: index out of bounds
L 07/30/2014 - 13:00:32: [AMXX] [0] new land.sma::replace_weapon_models (line 9246)
L 07/30/2014 - 13:00:32: [AMXX] [1] new land.sma::fw_Item_Deploy_Post (line 3047)
L 07/30/2014 - 13:00:33: [AMXX] Displaying debug trace (plugin "zombie_plague40.amxx")
Si estas usando g_arma_prim[id] como indice de otro array, pues usa 0 en lugar de -1
Mensajes: 417
Temas: 53
Registro en: May 2014
30/07/2014, 01:34 PM
(Última modificación: 30/07/2014, 01:36 PM por Ipolito.)
(30/07/2014, 01:15 PM)NikKOo31 escribió: (30/07/2014, 01:03 PM)Ipolito escribió: (30/07/2014, 12:19 PM)alan_el_more escribió: 1- fw_SetModel quedaría así
Código PHP: public fw_SetModel(entity, const model[]) { static classname[10] pev(entity, pev_classname, classname, charsmax(classname)) // Check if it's a weapon box if (equal(classname, "weaponbox")) { set_pev(entity, pev_iuser4 , g_arma_prim[pev( entity , pev_owner )]+1) return; } // code code }
2- Busca la funcion clcmd_drop y seguramente tendrás algo así, dependiendo de la versión que uses
Código PHP: public clcmd_drop(id) { // Survivor should stick with its weapon if (g_survivor[id] || g_currentweapon[id] == CSW_C4) return PLUGIN_HANDLED; return PLUGIN_CONTINUE; }
Agregale esto:
Código PHP: if((1<<get_user_weapon(id)) & PRIMARY_WEAPONS_BIT_SUM) g_arma_prim[id] = -1
Te quedaría así:
Código PHP: public clcmd_drop(id) { // Survivor should stick with its weapon if (g_survivor[id] || g_currentweapon[id] == CSW_C4) return PLUGIN_HANDLED; if((1<<get_user_weapon(id)) & PRIMARY_WEAPONS_BIT_SUM) g_arma_prim[id] = -1 return PLUGIN_CONTINUE; }
3- fw_TouchWeapon quedaría así
Código PHP: public fw_TouchWeapon(weapon, id) { // Not a player if (!is_user_valid_connected(id)) return HAM_IGNORED; // Dont pickup weapons if zombie or survivor (+PODBot MM fix) if (g_zombie[id] || (g_survivor[id] && !flag_get(g_isbot, id))) return HAM_SUPERCEDE; static iNum;iNum = pev(weapon, pev_iuser4) if(iNum > 0) g_arma_prim[id] = iNum return HAM_IGNORED; }
Lo puse tal cual me lo pasaste y ahora pasa esto u.u .
No se si al dropear el arma, o al agarrarla, te setea la variable g_arma_prim en -1, y queda asi.
Osea, al agarrar el arma no te setea la variable en el numero que se guardo en el arma :S .
PD: Y me sale esto en logs
L 07/30/2014 - 13:00:32: [AMXX] Run time error 4: index out of bounds
L 07/30/2014 - 13:00:32: [AMXX] [0] new land.sma::replace_weapon_models (line 9246)
L 07/30/2014 - 13:00:32: [AMXX] [1] new land.sma::fw_Item_Deploy_Post (line 3047)
L 07/30/2014 - 13:00:33: [AMXX] Displaying debug trace (plugin "zombie_plague40.amxx")
Si estas usando g_arma_prim[id] como indice de otro array, pues usa 0 en lugar de -1
Listo xD, ya no me da mas la cabeza.
Pero ahora otro problema
Al agarrar el arma no le setea al jugador la variable (?
Queda en 0
Mensajes: 1,616
Temas: 19
Registro en: Oct 2013
Reputación:
16
Probe esto y funciona:
Código PHP: #include <amxmodx> #include <fakemeta> #include <hamsandwich>
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)
new g_arma_prim[33] public plugin_init() { register_clcmd("say asd", "clcmd_asd") register_clcmd("drop", "clcmd_drop") RegisterHam(Ham_Spawn, "player", "fw_PlayerSpawn_Post", 1) RegisterHam(Ham_Touch, "weaponbox", "fw_TouchWeapon") register_forward(FM_SetModel, "fw_SetModel") }
public clcmd_asd(id) { client_print(id, 3, "g_arma_prim[id] == %d", g_arma_prim[id]) }
public clcmd_drop(id) { if((1<<get_user_weapon(id)) & PRIMARY_WEAPONS_BIT_SUM) { set_task(0.1, "Clear", id) } }
public Clear(id) { g_arma_prim[id] = -1 client_print(1, 3, "Clear() -1") }
public fw_PlayerSpawn_Post(id) { if(!is_user_alive(id)) return HAM_IGNORED client_print(id, 3, "g_arma_prim[id] == %d", g_arma_prim[id] = random(30)) return HAM_IGNORED }
public fw_TouchWeapon(weapon, id) { if(!is_user_connected(id)) return HAM_IGNORED static iNum;iNum = pev(weapon, pev_iuser4) if(iNum > -1) client_print(id, 3, "PEV_IUSER4: %d", iNum) return HAM_IGNORED }
public fw_SetModel(entity, const model[]) { // Get entity's classname static classname[10] pev(entity, pev_classname, classname, charsmax(classname)) // Check if it's a weapon box if (equal(classname, "weaponbox")) { client_print(1, 3, "SETMODEL - g_arma_prim[%d] == %d", pev(entity, pev_owner), g_arma_prim[pev(entity, pev_owner)]) set_pev(entity, pev_iuser4, g_arma_prim[pev(entity, pev_owner)]) } }
Con esto te podes guiar.
Ni te molestes en enviarme un mensaje privado para pedirme ayuda porque NO lo voy a contestar.
Gracias por su atención.
Mensajes: 417
Temas: 53
Registro en: May 2014
30/07/2014, 02:19 PM
(Última modificación: 30/07/2014, 02:40 PM por Ipolito.)
(30/07/2014, 02:00 PM)alan_el_more escribió: Probe esto y funciona:
Código PHP: #include <amxmodx> #include <fakemeta> #include <hamsandwich>
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)
new g_arma_prim[33] public plugin_init() { register_clcmd("say asd", "clcmd_asd") register_clcmd("drop", "clcmd_drop") RegisterHam(Ham_Spawn, "player", "fw_PlayerSpawn_Post", 1) RegisterHam(Ham_Touch, "weaponbox", "fw_TouchWeapon") register_forward(FM_SetModel, "fw_SetModel") }
public clcmd_asd(id) { client_print(id, 3, "g_arma_prim[id] == %d", g_arma_prim[id]) }
public clcmd_drop(id) { if((1<<get_user_weapon(id)) & PRIMARY_WEAPONS_BIT_SUM) { set_task(0.1, "Clear", id) } }
public Clear(id) { g_arma_prim[id] = -1 client_print(1, 3, "Clear() -1") }
public fw_PlayerSpawn_Post(id) { if(!is_user_alive(id)) return HAM_IGNORED client_print(id, 3, "g_arma_prim[id] == %d", g_arma_prim[id] = random(30)) return HAM_IGNORED }
public fw_TouchWeapon(weapon, id) { if(!is_user_connected(id)) return HAM_IGNORED static iNum;iNum = pev(weapon, pev_iuser4) if(iNum > -1) client_print(id, 3, "PEV_IUSER4: %d", iNum) return HAM_IGNORED }
public fw_SetModel(entity, const model[]) { // Get entity's classname static classname[10] pev(entity, pev_classname, classname, charsmax(classname)) // Check if it's a weapon box if (equal(classname, "weaponbox")) { client_print(1, 3, "SETMODEL - g_arma_prim[%d] == %d", pev(entity, pev_owner), g_arma_prim[pev(entity, pev_owner)]) set_pev(entity, pev_iuser4, g_arma_prim[pev(entity, pev_owner)]) } }
Con esto te podes guiar. Ahi te digo si me funciona
EDIT: Al fin JAJAJAJJAJA, ahora si, anda mas o menos bien u,u , que inutil que soy D:.
Ahora, tengo otro problema (? :S .
Si yo estoy parado arriba de X arma, qe tiene g_arma_prim = 20 por ej, y yo tengo un arma con la variable g_arma_prim = 25, al tirar el arma, me queda la variable g_arma_prim en 0 :/
|