AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   DeathMsg error (https://forums.alliedmods.net/showthread.php?t=328426)

karaulov 11-08-2020 13:30

DeathMsg error
 
Code:

        register_event("DeathMsg","EVENT_Death", "a", "1>0");
Code:

public EVENT_Death()
{
        //log_message("EVENT_Death")
        static killer_id, victim_id;
        killer_id = read_data(1);
        victim_id = read_data(2);
       
}

I got sometimes victim_id > 33, why?

AMX MODX 1.10 latest build

OciXCrom 11-08-2020 13:47

Re: DeathMsg error
 
Please show the full code with logs included.

karaulov 11-08-2020 22:24

Re: DeathMsg error
 
Quote:

Originally Posted by OciXCrom (Post 2724265)
Please show the full code with logs included.

Plugin not for public (For one my server)
I sent my plugin in PM.
But I add here && victim_id >= 0 && victim_id < 33 in 154 line.


I Use AMX MOD X 1.10 latest build.
Code:

public EVENT_Death()
{
        //log_message("EVENT_Death")
        static killer_id, victim_id;
        killer_id = read_data(1);
        victim_id = read_data(2);
       
}

Run time error 4: index out of bounds

g_PlayerData[victim_id]

Shadows Adi 11-09-2020 00:57

Re: DeathMsg error
 
You should always check if the entity is in range
PHP Code:

if ( !(<= victim_id <= 32) || !(<= killer_id<= 32) ) return PLUGIN_HANDLED 


karaulov 11-09-2020 03:27

Re: DeathMsg error
 
But who can be dead instead of the player??

Celena Luna 11-09-2020 03:38

Re: DeathMsg error
 
Quote:

Originally Posted by karaulov (Post 2724325)
But who can be dead instead of the player??

You can try to get the it class and find out what is it.
Who know? It happen all the time. And if it is not what we need, ignore it.
usually, if you just want player, check is_user_connected to bypass that out of bound error.


All times are GMT -4. The time now is 14:09.

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