[HELP]OnVehicleDeath Message doesn't send
#4

Your biggest problem is your using "return" in a loop. That will Break the loop, and we don't want that.

I haven't tested this, but you could give it a shot:

pawn Код:
public OnVehicleDeath(vehicleid)
{
    foreach(Player, i)
    {
        new string[64], str[128], plname[MAX_PLAYER_NAME];
        GetPlayerName(i, plname, sizeof(plname));

        if(strcmp(plname, VehicleInfo[vehicleid][vOwner], true) != 0) continue;
        if(VehicleInfo[vehicleid][vOwned] == 0) continue;
       
        if(VehicleInfo[vehicleid][vInsurances] >= 1)
        {
            VehicleInfo[vehicleid][vInsurances]--;
            VehicleInfo[vehicleid][vScratch] ++;
           
            new file[128];
            format(file, sizeof(file), "Vehicles/Vehicles/%s.%s.cfg", plname, VehicleNames[GetVehicleModel(vehicleid)-400]);
           
            if(dini_Exists(file))
            {
                dini_IntSet(file, "Scratches", VehicleInfo[vehicleid][vScratch]);
                dini_IntSet(file, "Insurances", VehicleInfo[vehicleid][vInsurances]);
            }
           
            DestroyVehicle(vehicleid);
            SetVehicleToRespawn(vehicleid);
           
            format(string, sizeof(string), "You have %d insurance left.", VehicleInfo[vehicleid][vInsurances]);
            SendClientMessage(i, COLOR_LIGHTRED, string);
           
            format(string, sizeof(string), "You have now %d Scratches in your car.", VehicleInfo[vehicleid][vScratch]);
            SendClientMessage(i, COLOR_LIGHTRED, string);
            continue;
        }
        else
        {
            if(strfind(plname, VehicleInfo[vehicleid][vOwner], true) != 0) continue;

            format(string, sizeof(string), "You have 0 insurance left and now your car has been destroyed.");
            SendClientMessage(i, COLOR_LIGHTRED, string);
            GetPlayerName(i, plname, sizeof(plname));

            format(string, sizeof(string), "Vehicles/Vehicles/%s.%s.cfg", plname, VehicleNames[GetVehicleModel(vehicleid)-400]);
            format(str, sizeof(str), "%s.%s.cfg", plname, VehicleNames[GetVehicleModel(vehicleid)-400]);
           
            if(strfind(str, PlayerVehicle[i][pVeh1], true) == 0)
            {
                DestroyVehicle(vehicleid);
                fremove(string);
                strmid(PlayerVehicle[i][pVeh1], "None", 0, strlen("None"), 255);
                continue;
            }
            else if(strfind(str, PlayerVehicle[i][pVeh2], true) == 0)
            {
                DestroyVehicle(vehicleid);
                fremove(string);
                strmid(PlayerVehicle[i][pVeh2], "None", 0, strlen("None"), 255);
                continue;
            }
            else if(strfind(str, PlayerVehicle[i][pVeh3], true) == 0)
            {
                DestroyVehicle(vehicleid);
                fremove(string);
                strmid(PlayerVehicle[i][pVeh3], "None", 0, strlen("None"), 255);
                continue;
            }
            else if(strfind(str, PlayerVehicle[i][pVeh4], true) == 0)
            {
                DestroyVehicle(vehicleid);
                fremove(string);
                strmid(PlayerVehicle[i][pVeh4], "None", 0, strlen("None"), 255);
                continue;
            }
            else if(strfind(str, PlayerVehicle[i][pVeh5], true) == 0)
            {
                DestroyVehicle(vehicleid);
                fremove(string);
                strmid(PlayerVehicle[i][pVeh5], "None", 0, strlen("None"), 255);
                continue;
            }
        }
    }
    return 1;
}
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 3 Guest(s)