Raised This Month: $ Target: $400
 0% 

Ayuda con index out of bound


  
 
 
Thread Tools Display Modes
Author Message
StrikerV2
Senior Member
Join Date: Nov 2012
Location: Chile , O Yes!
Old 04-10-2013 , 19:46   Ayuda con index out of bound
#1

bueno quisiera una ayuda con el chequeo :

public fw_PlayerKilled( victim, attacker )
{
if( !g_conectado[ victim ] || !g_conectado[ attacker ] || !is_user_alive( attacker ) || !is_user_alive( victim ) )
return

g_exp[ attacker ]++;
}

ya que me dijieron que podia tirar el error de index out of bound y bueno quisiera una ayuda para evitar futuros problemas. c:
__________________
Mi firma era tan sexy .-.
StrikerV2 is offline
Send a message via MSN to StrikerV2
YakumoHiratsuhi
Veteran Member
Join Date: Dec 2010
Location: Dreαmlαnd.
Old 04-10-2013 , 20:10   Re: Ayuda con index out of bound
#2

chequea que el atacante este dentro del rango de los jugadores (1~32).

PHP Code:
new g_maxplayers get_maxplayers () // global (caché)
if(<= attacker <= g_maxplayers// para saber si esta entre 1 y *numero de jugadores maximos del server* 
__________________
"Podra parecer ridiculo o imposible, pero este es el camino que seguimos los verdaderos hombres, si hay un muro en el camino, lo derribamos, si no hay camino, haremos uno, con nuestras propias manos, porque el magma de nuestro corazón arde en llamas."
YakumoHiratsuhi is offline
Send a message via MSN to YakumoHiratsuhi
StrikerV2
Senior Member
Join Date: Nov 2012
Location: Chile , O Yes!
Old 04-10-2013 , 21:57   Re: Ayuda con index out of bound
#3

Quote:
Originally Posted by YakumoHiratsuhi View Post
chequea que el atacante este dentro del rango de los jugadores (1~32).

PHP Code:
[PHP]new g_maxplayers get_maxplayers () // global (caché)
if(<= attacker <= g_maxplayers// para saber si esta entre 1 y *numero de jugadores maximos del server* 
[/PHP]
PHP Code:


new g_maxplayers;

g_maxplayers get_maxplayers( );

public 
fw_PlayerKilledvictimattacker 
{
    if( !( 
<= victim <= g_maxplayers ) || !( <= attacker >= g_maxplayers ) )
        return;
    
    
    if( 
get_user_teamattacker ) == && get_user_teamvictim ) == 2)
        
g_expattacker ]++;

ya no me tira index out bound en consola. c:

gracias.
__________________
Mi firma era tan sexy .-.

Last edited by StrikerV2; 04-10-2013 at 21:58.
StrikerV2 is offline
Send a message via MSN to StrikerV2
YakumoHiratsuhi
Veteran Member
Join Date: Dec 2010
Location: Dreαmlαnd.
Old 04-10-2013 , 23:22   Re: Ayuda con index out of bound
#4

hm no es necesario chequear la victima, con el atacante basta, puedes hacer un macro tambien para checarlo.

if(!(1 <= attacker <= g_maxplayers))
__________________
"Podra parecer ridiculo o imposible, pero este es el camino que seguimos los verdaderos hombres, si hay un muro en el camino, lo derribamos, si no hay camino, haremos uno, con nuestras propias manos, porque el magma de nuestro corazón arde en llamas."

Last edited by YakumoHiratsuhi; 04-10-2013 at 23:22.
YakumoHiratsuhi is offline
Send a message via MSN to YakumoHiratsuhi
DJHD!
Veteran Member
Join Date: Dec 2009
Location: Santiago, Chile
Old 04-11-2013 , 01:12   Re: Ayuda con index out of bound
#5

Esto es mucho mejor.

PHP Code:
#include <amxmodx>
#include <hamsandwich>

#define IsUserValidConnected(%1) (1 <= %1 <= gMaxPlayers && gConnected[%1])

new gMaxPlayersgConnected[33], gExp[33]

public 
plugin_init()
{
    
register_plugin("Is User Valid Connected""1.0""?")
    
    
RegisterHam(Ham_Killed"player""fw_PlayerKilled")
    
    
gMaxPlayers get_maxplayers()
}

public 
client_putinserver(id)
    
gConnected[id] = true

public client_disconnect(id)
    
gConnected[id] = false

public fw_PlayerKilled(victimattacker)  

    if (!
IsUserValidConnected(attacker)) 
        return 
HAM_IGNORED
    
    
if(get_user_team(attacker) == && get_user_team(victim) == 2
        
gExp[attacker]++
        
    return 
HAM_SUPERCEDE;

__________________
Quote:
Originally Posted by XINLEI View Post
Porque rocccos trata de ser el metalicross que nunca va a poder ser.

Last edited by DJHD!; 04-11-2013 at 01:13.
DJHD! is offline
Send a message via MSN to DJHD!
LeeanAndNeka
Senior Member
Join Date: Feb 2012
Location: Argentina ♥
Old 04-11-2013 , 11:16   Re: Ayuda con index out of bound
#6

Recuerden que get_user_team puede dar un valor numerico falso.
LeeanAndNeka is offline
Send a message via MSN to LeeanAndNeka Send a message via Skype™ to LeeanAndNeka
baneado
Veteran Member
Join Date: Dec 2012
Location: amxmodx-es.com
Old 04-11-2013 , 11:45   Re: Ayuda con index out of bound
#7

No hace falta chequear si son de equipos contrarios, cuando un jugador mata a otro es porque es del equipo enemigo...
baneado is offline
Roccoxx
AlliedModders Donor
Join Date: Jan 2012
Location: Argentina
Old 04-11-2013 , 13:33   Re: Ayuda con index out of bound
#8

Quote:
Originally Posted by baneado View Post
No hace falta chequear si son de equipos contrarios, cuando un jugador mata a otro es porque es del equipo enemigo...
y el friendlyfire?
__________________
Tutorials here (Spanish)

Like as another Pijudo said: "Tired and retired"

Quote:
Originally Posted by Jhob94 View Post
Attach the sma to the thread
Roccoxx is offline
Send a message via MSN to Roccoxx
baneado
Veteran Member
Join Date: Dec 2012
Location: amxmodx-es.com
Old 04-11-2013 , 15:39   Re: Ayuda con index out of bound
#9

Quote:
Originally Posted by Roccoxx View Post
y el friendlyfire?
jajajajaja no creo que lo tenga activado
baneado is offline
Roccoxx
AlliedModders Donor
Join Date: Jan 2012
Location: Argentina
Old 04-11-2013 , 15:59   Re: Ayuda con index out of bound
#10

Quote:
Originally Posted by baneado View Post
jajajajaja no creo que lo tenga activado
le preguntaste acaso? e.e
__________________
Tutorials here (Spanish)

Like as another Pijudo said: "Tired and retired"

Quote:
Originally Posted by Jhob94 View Post
Attach the sma to the thread
Roccoxx is offline
Send a message via MSN to Roccoxx
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 02:07.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode