What is the problem?
#5

Quote:
Originally Posted by Cell_
Посмотреть сообщение
From the data you have provided, I am guessing victimid is out of bounds, i.e, < 0 or > MAX_PLAYERS, assuming the User array is sized MAX_PLAYERS. Will have to see the GetClosestPlayer function to make sure that's the case.
On the assumption that that is the case, perhaps you should have some sort of a check on victimid before implementing the rest of the code. Something like:
pawn Код:
if(victimid >= sizeof(Users) || victimid < 0) return 1;
Adding this to the after the new victimid = GetClosestPlayer(playerid,2.0) part of this code might help. I am also assuming this code is under OnPlayerKeyStateChange so playerid is not out of bound.

Making the final code look something like this:
pawn Код:
if(Team[playerid] == Zombies && User[playerid][USER_MINIJUE]==0 && User[playerid][USER_Evento] == 0 && User[playerid][USER_TipoD]==0 && newkeys & Morder)
    {
    if(GetPlayerWeapon(playerid) == 0)
    {
    new victimid = GetClosestPlayer(playerid,2.0);
   
    if(victimid >= sizeof(Users) || victimid < 0) return 1; // can also replace sizeof(Users) with MAX_PLAYERS but you can only do this if your Users variable looks something like this Users[MAX_PLAYERS][someEnum]
   
    if(Team[victimid] != Zombies )
    {
    if(IsPlayerPaused (victimid)) return GameTextForPlayer(playerid, "~G~El jugador se encuentra~N~ pausado", 6000, 4);
    new Float: Health;
    GetPlayerHealth(victimid, Health);

    switch(User[playerid][USER_Mutacion]) {
    case 0,2: {
    if(Health <= 10 && User[victimid][USER_Muerto]== 0 )SendDeathMessage(playerid,victimid,WEAPON_DROWN),User[playerid][USER_KILLS]++,User[victimid][USER_Muerto]=1;
    code.
    .
    .
    . }
    case 1: {
    if(Health <= 20 && User[victimid][USER_Muerto]== 0 )SendDeathMessage(playerid,victimid,WEAPON_DROWN),User[playerid][USER_KILLS]++,User[victimid][USER_Muerto]=1;
    code .
    .
    .
    . }
    }
    SetPlayerScore(playerid,User[playerid][USER_SCORE]);
    }
    }
    return 1;
    }
PHP код:
stock Float:GetDistanceBetweenPoints(Float:rx1,Float:ry1,Float:rz1,Float:rx2,Float:ry2,Float:rz2)
{
    return 
floatadd(floatadd(floatsqroot(floatpower(floatsub(rx1rx2), 2)), floatsqroot(floatpower(floatsub(ry1ry2), 2))), floatsqroot(floatpower(floatsub(rz1rz2), 2)));
}
stock GetClosestPlayer(playeridFloat:limit)
{
    new 
Float:x1Float:y1Float:z1Float:x2Float:y2Float:z2Float:Distid INVALID_PLAYER_ID;
    
GetPlayerPos(playerid,x1,y1,z1);
    for(new 
0MAX_PLAYERSi++)
    {
        if(!
IsPlayerConnected(i)) continue;
        if(
== playerid) continue;
        
GetPlayerPos(ix2y2z2);
        
Dist GetDistanceBetweenPoints(x1y1z1x2y2z2);
        if(
Dist limit || id == INVALID_PLAYER_ID)
        {
            
limit Dist;
            
id i;
        }
    }
    return 
id;

It's the function
Reply


Messages In This Thread
What is the problem? - by Daynox12 - 02.06.2018, 19:24
Re: What is the problem? - by HoNEYKISS - 02.06.2018, 19:31
Re: What is the problem? - by Cell_ - 02.06.2018, 19:43
Re: What is the problem? - by Daynox12 - 02.06.2018, 19:43
Re: What is the problem? - by Daynox12 - 02.06.2018, 19:59
Re: What is the problem? - by Cell_ - 02.06.2018, 20:10
Re: What is the problem? - by Daynox12 - 02.06.2018, 20:12
Re: What is the problem? - by Daynox12 - 02.06.2018, 21:37
Re: What is the problem? - by Cell_ - 02.06.2018, 22:03
Re: What is the problem? - by GTLS - 03.06.2018, 06:11

Forum Jump:


Users browsing this thread: 1 Guest(s)