Создание файла(название файла = поряд. ид авто)
#7

pawn Code:
foundVehicleNearPlayer(playerid, inputtext[])
{
    if (playerid == INVALID_PLAYER_ID || strlen(inputtext) == 0) return 0;
    if (!IsPlayerConnected(playerid) && IsPlayerNPC(playerid)) return 0;
   
    new Float:playerPosition[3], foundVehicle = INVALID_VEHICLE_ID;
    GetPlayerPos(playerid, playerPosition[0], playerPosition[1], playerPosition[2]);
    for (new vehicleid, Float:distance, Flaot:vehiclePosition[3], Float:smallestDistance = 9999.9; vehicleid < MAX_VEHICLES; vehicleid++)
    {
        if (GetVehicleModel(vehicleid) == 0) continue;
        GetVehiclePos(vehicleid, vehiclePosition[0], vehiclePosition[1], vehiclePosition[2]);
        distance = floatsqroot(floatpower((vehiclePosition[0] - playerPosition[0]), 2.0) + floatpower((vehiclePosition[1] - playerPosition[1]), 2.0) + floatpower((vehiclePosition[2] - playerPosition[2]), 2.0))
        if (floatcmp(smallestDistance, distance) != -1)
        {
            foundVehicle = vehicleid;
            distance = smallestDistance;
        }
    }
    if (foundVehicle != INVALID_VEHICLE_ID)
    {
        new accounName[64];
        format(accountName, sizeof(accountName), "%d.ini", foundVehicle);
        new file = ini_createFile(accountName);
        if (file < 0)
        {
            file = ini_openFile(accountName);
        }
       
        if (0 <= file)
        {
            ini_setInteger(file, "Price", strval(inputtext));
            ini_closeFile(file);
            return 1;
        }
    }
    return 0;
}
на работоспособность не проверял, но компилируется без ошибок.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)