Getting (null : 0x(nil)) In BodyPart

Started by MacTavish, Mar 16, 2015, 06:24 PM

Previous topic - Next topic

MacTavish

Guys sometimes when a player kill other player i get this.. I've checked every part of body it works fine but its appears sometimes

<&EFS4BOT> [11:15:05] >> *** KAKAN ( 1 ) killed =ShaH= ( 0 )   ( M4  (null : 0x(nil)) : 100% Health Left )
<&EFS4BOT> [11:18:42] >> *** KAKAN ( 1 ) killed =ShaH= ( 0 )   (  M4   (null : 0x(nil)) :  100% Health Left  )
<&EFS4BOT> [11:23:31] >> *** KAKAN ( 1 ) killed =ShaH= ( 0 )  ( Stubby Shotgun  Left Arm : 100% Health Left )

Here is my BodyPart Function

function GetBPName( bodypart )
{
    local bpd;
switch( bodypart.tointeger() )
{
    case 0:
bpd = "Body";
break;

case 1:
bpd = "Torso";
break;

case 2:
bpd = "Left Arm";
break;

case 3:
bpd = "Right Arm";
break;

case 4:
bpd = "Left Leg";
break;

case 5:
bpd = "Right Leg";
break;

case 6:
bpd = "Head";
break;
}
    return bpd;
}


It Seems Fine But if it is fine then whats wrong :/

Grand Hunting Project
Join #SLC, #KAKAN, #Doom, #GHP @LUnet

Retired VC:MP Player/Scripter :P

.

No need to use a local variable just for that. You can return directly from the switch case:
function GetBPName(bodypart)
{
    local bpid = -1;

    try {
        bpid = bodypart.tointeger();
    } catch (e) {
        print("Failed: " + e);
    }

    switch(bpid)
    {
        case BODYPART_BODY:     return "Body";
        case BODYPART_TORSO:    return "Torso";
        case BODYPART_LEFTARM:  return "Left Arm";
        case BODYPART_RIGHTARM: return "Right Arm";
        case BODYPART_LEFTLEG:  return "Left Leg";
        case BODYPART_RIGHTLEG: return "Right Leg";
        case BODYPART_HEAD:     return "Head";
        default:                return "Unknown";
    }
}
.

MacTavish

Thanks S.L.C its seems working fine now  :)

Grand Hunting Project
Join #SLC, #KAKAN, #Doom, #GHP @LUnet

Retired VC:MP Player/Scripter :P